Class NacosSkillRepository

java.lang.Object
io.agentscope.core.nacos.skill.NacosSkillRepository
All Implemented Interfaces:
io.agentscope.core.skill.repository.AgentSkillRepository, AutoCloseable

public class NacosSkillRepository extends Object implements io.agentscope.core.skill.repository.AgentSkillRepository
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 Details

  • Constructor Details

    • NacosSkillRepository

      public NacosSkillRepository(com.alibaba.nacos.api.ai.AiService aiService, String namespaceId)
    • NacosSkillRepository

      public NacosSkillRepository(com.alibaba.nacos.api.ai.AiService aiService, String namespaceId, Properties properties)
      Same as NacosSkillRepository(AiService, String, Properties, List) with an empty knownSkillNames.
    • NacosSkillRepository

      public NacosSkillRepository(com.alibaba.nacos.api.ai.AiService aiService, String namespaceId, Properties properties, List<String> knownSkillNames)
      Creates a repository for the given Nacos namespace; resolves skill version and label once (see class Javadoc for precedence).
      Parameters:
      aiService - the Nacos AI service (must not be null)
      namespaceId - the Nacos namespace id (blank treated as public)
      properties - optional application properties; may be null
      knownSkillNames - skill names to expose via getAllSkillNames() and getAllSkills(); pass empty list to keep the no-op behaviour
  • Method Details

    • getSkill

      public io.agentscope.core.skill.AgentSkill getSkill(String name)
      Specified by:
      getSkill in interface io.agentscope.core.skill.repository.AgentSkillRepository
    • skillExists

      public boolean skillExists(String skillName)
      Specified by:
      skillExists in interface io.agentscope.core.skill.repository.AgentSkillRepository
    • getRepositoryInfo

      public io.agentscope.core.skill.repository.AgentSkillRepositoryInfo getRepositoryInfo()
      Specified by:
      getRepositoryInfo in interface io.agentscope.core.skill.repository.AgentSkillRepository
    • getSource

      public String getSource()
      Specified by:
      getSource in interface io.agentscope.core.skill.repository.AgentSkillRepository
    • setWriteable

      public void setWriteable(boolean writeable)
      Specified by:
      setWriteable in interface io.agentscope.core.skill.repository.AgentSkillRepository
    • isWriteable

      public boolean isWriteable()
      Specified by:
      isWriteable in interface io.agentscope.core.skill.repository.AgentSkillRepository
    • getAllSkillNames

      public List<String> getAllSkillNames()
      Specified by:
      getAllSkillNames in interface io.agentscope.core.skill.repository.AgentSkillRepository
    • getAllSkills

      public List<io.agentscope.core.skill.AgentSkill> getAllSkills()
      Specified by:
      getAllSkills in interface io.agentscope.core.skill.repository.AgentSkillRepository
    • save

      public boolean save(List<io.agentscope.core.skill.AgentSkill> skills, boolean force)
      Specified by:
      save in interface io.agentscope.core.skill.repository.AgentSkillRepository
    • delete

      public boolean delete(String skillName)
      Specified by:
      delete in interface io.agentscope.core.skill.repository.AgentSkillRepository
    • close

      public void close()
      Specified by:
      close in interface io.agentscope.core.skill.repository.AgentSkillRepository
      Specified by:
      close in interface AutoCloseable