Class ClassPathSkillSource

java.lang.Object
com.google.adk.skills.AbstractSkillSource<com.google.common.reflect.ClassPath.ResourceInfo>
com.google.adk.skills.ClassPathSkillSource
All Implemented Interfaces:
SkillSource

public final class ClassPathSkillSource extends AbstractSkillSource<com.google.common.reflect.ClassPath.ResourceInfo>
Loads skills from the classpath.
  • Constructor Details

    • ClassPathSkillSource

      public ClassPathSkillSource(String baseResourcePath)
      Creates a new ClassPathSkillSource that loads skills from the given base resource path using the current thread's context class loader.
      Parameters:
      baseResourcePath - the base classpath path to scan for skills (e.g., "skills/")
    • ClassPathSkillSource

      public ClassPathSkillSource(String baseResourcePath, ClassLoader classLoader)
      Creates a new ClassPathSkillSource that loads skills from the given base resource path using the specified ClassLoader.
      Parameters:
      baseResourcePath - the base classpath path to scan for skills
      classLoader - the class loader to use for scanning resources
  • Method Details

    • listResources

      public io.reactivex.rxjava3.core.Single<com.google.common.collect.ImmutableList<String>> listResources(String skillName, String resourceDirectory)
      Description copied from interface: SkillSource
      Lists all resource files for a specific skill within a given directory.

      If the skill or the resource directory does not exist, the returned Single will terminate with a SkillSourceException.

      Parameters:
      skillName - the name of the skill
      resourceDirectory - the relative directory within the skill to list (e.g., "assets", "scripts")
      Returns:
      a Single emitting a list of resource paths relative to the skill directory
    • listSkills

      protected io.reactivex.rxjava3.core.Flowable<AbstractSkillSource.SkillMdPath<com.google.common.reflect.ClassPath.ResourceInfo>> listSkills()
      Description copied from class: AbstractSkillSource
      Returns a Flowable of skills as a pair of skill name and the path to the SKILL.md file.
      Specified by:
      listSkills in class AbstractSkillSource<com.google.common.reflect.ClassPath.ResourceInfo>
    • findSkillMdPath

      protected io.reactivex.rxjava3.core.Single<com.google.common.reflect.ClassPath.ResourceInfo> findSkillMdPath(String skillName)
      Description copied from class: AbstractSkillSource
      Returns the path to the SKILL.md file for the given skill.
      Specified by:
      findSkillMdPath in class AbstractSkillSource<com.google.common.reflect.ClassPath.ResourceInfo>
    • findResourcePath

      protected io.reactivex.rxjava3.core.Single<com.google.common.reflect.ClassPath.ResourceInfo> findResourcePath(String skillName, String resourcePath)
      Description copied from class: AbstractSkillSource
      Returns the path to the resource for the given skill.
      Specified by:
      findResourcePath in class AbstractSkillSource<com.google.common.reflect.ClassPath.ResourceInfo>
    • openChannel

      protected ReadableByteChannel openChannel(com.google.common.reflect.ClassPath.ResourceInfo path) throws IOException
      Description copied from class: AbstractSkillSource
      Opens a InputStream for reading the content of the given path.
      Specified by:
      openChannel in class AbstractSkillSource<com.google.common.reflect.ClassPath.ResourceInfo>
      Throws:
      IOException