Class AbstractSkillSource<PathT>

java.lang.Object
com.google.adk.skills.AbstractSkillSource<PathT>
Type Parameters:
PathT - the type of path object
All Implemented Interfaces:
SkillSource
Direct Known Subclasses:
LocalSkillSource

public abstract class AbstractSkillSource<PathT> extends Object implements SkillSource
Abstract base class for SkillSource implementations that load skills from path like object.
  • Constructor Details

    • AbstractSkillSource

      public AbstractSkillSource()
  • Method Details

    • listFrontmatters

      public io.reactivex.rxjava3.core.Single<com.google.common.collect.ImmutableMap<String, Frontmatter>> listFrontmatters()
      Description copied from interface: SkillSource
      Lists all available Frontmatters for discovered skills.

      If the source is misconfigured, such as directory doesn't exist, or having malformed skill, the returned Single will terminate with a SkillSourceException with the reason in the message.

      Specified by:
      listFrontmatters in interface SkillSource
      Returns:
      a Single emitting a map where keys are skill names and values are their Frontmatter
    • loadFrontmatter

      public io.reactivex.rxjava3.core.Single<Frontmatter> loadFrontmatter(String skillName)
      Description copied from interface: SkillSource
      Loads the Frontmatter for a specific skill.

      If the skill is not found or its frontmatter is malformed, the returned Single will terminate with a SkillSourceException or parsing error.

      Specified by:
      loadFrontmatter in interface SkillSource
      Parameters:
      skillName - the name of the skill
      Returns:
      a Single emitting the Frontmatter for the skill
    • loadInstructions

      public io.reactivex.rxjava3.core.Single<String> loadInstructions(String skillName)
      Description copied from interface: SkillSource
      Loads the instructions (body of SKILL.md) for a specific skill.

      If the skill is not found or its file structure is invalid (e.g., unclosed frontmatter blocks), the returned Single will terminate with a SkillSourceException.

      Specified by:
      loadInstructions in interface SkillSource
      Parameters:
      skillName - the name of the skill
      Returns:
      a Single emitting the instructions as a String
    • loadResource

      public io.reactivex.rxjava3.core.Single<com.google.common.io.ByteSource> loadResource(String skillName, String resourcePath)
      Description copied from interface: SkillSource
      Loads a specific resource file content.

      If the skill or the specific resource path cannot be found, the returned Single will terminate with a SkillSourceException.

      Specified by:
      loadResource in interface SkillSource
      Parameters:
      skillName - the name of the skill
      resourcePath - the path to the resource file relative to the skill directory
      Returns:
      a Single emitting the ByteSource for the resource content
    • listSkills

      protected abstract io.reactivex.rxjava3.core.Flowable<AbstractSkillSource<PathT>.SkillMdPath> listSkills()
      Returns a Flowable of skills as a pair of skill name and the path to the SKILL.md file.
    • findSkillMdPath

      protected abstract io.reactivex.rxjava3.core.Single<PathT> findSkillMdPath(String skillName)
      Returns the path to the SKILL.md file for the given skill.
    • findResourcePath

      protected abstract io.reactivex.rxjava3.core.Single<PathT> findResourcePath(String skillName, String resourcePath)
      Returns the path to the resource for the given skill.
    • openChannel

      protected abstract ReadableByteChannel openChannel(PathT path) throws IOException
      Opens a InputStream for reading the content of the given path.
      Throws:
      IOException