NacosSkillRepository
public class NacosSkillRepository implements AgentSkillRepository
io/agentscope/core/nacos/skill/NacosSkillRepository.java:74–549Nacos 技能仓库,负责持久化与读取数据。位于 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_PATHstaticfinal | String | 技能版本路径字段。 Key for skill version in `Properties`, JVM `System#getProperty(String)`, etc. |
SKILL_LABEL_PATHstaticfinal | String | 技能标签路径字段。 Key for skill label in `Properties`, JVM `System#getProperty(String)`, etc. |
ENV_SKILL_VERSION_PATHstaticfinal | String | ENV 技能版本路径字段。 Environment variable name for skill version (fallback after properties and JVM). |
ENV_SKILL_LABEL_PATHstaticfinal | 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
技能版本路径字段。声明为 public static final String SKILL_VERSION_PATH。
Key for skill version in Properties, JVM System#getProperty(String), etc.
io/agentscope/core/nacos/skill/NacosSkillRepository.java:91SKILL_LABEL_PATH
public static final String SKILL_LABEL_PATH
技能标签路径字段。声明为 public static final String SKILL_LABEL_PATH。
Key for skill label in Properties, JVM System#getProperty(String), etc.
io/agentscope/core/nacos/skill/NacosSkillRepository.java:94ENV_SKILL_VERSION_PATH
public static final String ENV_SKILL_VERSION_PATH
ENV 技能版本路径字段。声明为 public static final String ENV_SKILL_VERSION_PATH。
Environment variable name for skill version (fallback after properties and JVM).
io/agentscope/core/nacos/skill/NacosSkillRepository.java:97ENV_SKILL_LABEL_PATH
public static final String ENV_SKILL_LABEL_PATH
ENV 技能标签路径字段。声明为 public static final String ENV_SKILL_LABEL_PATH。
Environment variable name for skill label (fallback after properties and JVM).
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.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
aiService | AiService | ai 服务(类型 `AiService`)。The ai service. |
namespaceId | String | 命名空间标识(类型 `String`)。The namespace id. |
io/agentscope/core/nacos/skill/NacosSkillRepository.java:114–116NacosSkillRepository
public NacosSkillRepository(AiService aiService, String namespaceId, Properties properties)
初始化 NacosSkillRepository 实例。
Same as #NacosSkillRepository(AiService, String, Properties, List) with an empty knownSkillNames.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
aiService | AiService | ai 服务(类型 `AiService`)。The ai service. |
namespaceId | String | 命名空间标识(类型 `String`)。The namespace id. |
properties | Properties | 属性(类型 `Properties`)。The properties. |
io/agentscope/core/nacos/skill/NacosSkillRepository.java:122–124NacosSkillRepository
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).
| 名称Name | 类型Type | 说明Description |
|---|---|---|
aiService | AiService | ai 服务(类型 `AiService`)。the Nacos AI service (must not be null) |
namespaceId | String | 命名空间标识(类型 `String`)。the Nacos namespace id (blank treated as `public`) |
properties | Properties | 属性(类型 `Properties`)。optional application properties; may be `null` |
knownSkillNames | List<String> | known 技能 Names(类型 `List`)。skill names to expose via `#getAllSkillNames()` and `#getAllSkills()`; pass empty list to keep the no-op behaviour |
io/agentscope/core/nacos/skill/NacosSkillRepository.java:136–168方法详情Method Detail
getSkill
public AgentSkill getSkill(String name)
获取技能。
Returns the skill.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
name | String | 名称(类型 `String`)。The name. |
AgentSkillio/agentscope/core/nacos/skill/NacosSkillRepository.java:170–188skillExists
public boolean skillExists(String skillName)
设置该参数。
Performs the skill exists operation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
skillName | String | 技能名称(类型 `String`)。The skill name. |
booleanio/agentscope/core/nacos/skill/NacosSkillRepository.java:190–205getRepositoryInfo
public AgentSkillRepositoryInfo getRepositoryInfo()
获取仓库信息。
Returns the repository info.
AgentSkillRepositoryInfoio/agentscope/core/nacos/skill/NacosSkillRepository.java:207–210getSource
public String getSource()
获取来源。
Returns the source.
Stringio/agentscope/core/nacos/skill/NacosSkillRepository.java:212–215setWriteable
public void setWriteable(boolean writeable)
设置 setWriteable。
Sets the writeable.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
writeable | boolean | writeable(类型 `boolean`)。The writeable. |
io/agentscope/core/nacos/skill/NacosSkillRepository.java:217–220isWriteable
public boolean isWriteable()
判断是否 isWriteable。
Returns whether the writeable.
booleanio/agentscope/core/nacos/skill/NacosSkillRepository.java:222–225getAllSkillNames
public List<String> getAllSkillNames()
获取 getAllSkillNames。
Returns the all skill names.
List<String>io/agentscope/core/nacos/skill/NacosSkillRepository.java:229–238getAllSkills
public List<AgentSkill> getAllSkills()
获取所有技能。
Returns the all skills.
List<AgentSkill>io/agentscope/core/nacos/skill/NacosSkillRepository.java:240–258save
public boolean save(List<AgentSkill> skills, boolean force)
保存数据到持久化存储。
Performs the save operation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
skills | List<AgentSkill> | 技能(类型 `List`)。The skills. |
force | boolean | force(类型 `boolean`)。The force. |
booleanio/agentscope/core/nacos/skill/NacosSkillRepository.java:260–264delete
public boolean delete(String skillName)
删除数据。
Performs the delete operation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
skillName | String | 技能名称(类型 `String`)。The skill name. |
booleanio/agentscope/core/nacos/skill/NacosSkillRepository.java:266–270close
public void close()
关闭连接并释放相关资源。
Releases resources and connections.
io/agentscope/core/nacos/skill/NacosSkillRepository.java:272–275