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.
-
Nested Class Summary
Nested classes/interfaces inherited from class AbstractSkillSource
AbstractSkillSource.SkillMdPath<PathT>Modifier and TypeClassDescriptionstatic final classA container class that holds a skill's name and the path to its SKILL.md file. -
Constructor Summary
ConstructorsConstructorDescriptionClassPathSkillSource(String baseResourcePath) Creates a newClassPathSkillSourcethat loads skills from the given base resource path using the current thread's context class loader.ClassPathSkillSource(String baseResourcePath, ClassLoader classLoader) Creates a newClassPathSkillSourcethat loads skills from the given base resource path using the specifiedClassLoader. -
Method Summary
Modifier and TypeMethodDescriptionprotected io.reactivex.rxjava3.core.Single<com.google.common.reflect.ClassPath.ResourceInfo> findResourcePath(String skillName, String resourcePath) Returns the path to the resource for the given skill.protected io.reactivex.rxjava3.core.Single<com.google.common.reflect.ClassPath.ResourceInfo> findSkillMdPath(String skillName) Returns the path to the SKILL.md file for the given skill.io.reactivex.rxjava3.core.Single<com.google.common.collect.ImmutableList<String>> listResources(String skillName, String resourceDirectory) Lists all resource files for a specific skill within a given directory.protected io.reactivex.rxjava3.core.Flowable<AbstractSkillSource.SkillMdPath<com.google.common.reflect.ClassPath.ResourceInfo>> Returns aFlowableof skills as a pair of skill name and the path to the SKILL.md file.protected ReadableByteChannelopenChannel(com.google.common.reflect.ClassPath.ResourceInfo path) Opens aInputStreamfor reading the content of the given path.Methods inherited from class AbstractSkillSource
listFrontmatters, loadFrontmatter, loadInstructions, loadResourceModifier and TypeMethodDescriptionio.reactivex.rxjava3.core.Single<com.google.common.collect.ImmutableMap<String, Frontmatter>> Lists all availableFrontmatters for discovered skills.io.reactivex.rxjava3.core.Single<Frontmatter> loadFrontmatter(String skillName) Loads theFrontmatterfor a specific skill.io.reactivex.rxjava3.core.Single<String> loadInstructions(String skillName) Loads the instructions (body of SKILL.md) for a specific skill.io.reactivex.rxjava3.core.Single<com.google.common.io.ByteSource> loadResource(String skillName, String resourcePath) Loads a specific resource file content.
-
Constructor Details
-
ClassPathSkillSource
Creates a newClassPathSkillSourcethat 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
Creates a newClassPathSkillSourcethat loads skills from the given base resource path using the specifiedClassLoader.- Parameters:
baseResourcePath- the base classpath path to scan for skillsclassLoader- 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:SkillSourceLists all resource files for a specific skill within a given directory.If the skill or the resource directory does not exist, the returned
Singlewill terminate with aSkillSourceException.- Parameters:
skillName- the name of the skillresourceDirectory- the relative directory within the skill to list (e.g., "assets", "scripts")- Returns:
- a
Singleemitting 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:AbstractSkillSourceReturns aFlowableof skills as a pair of skill name and the path to the SKILL.md file.- Specified by:
listSkillsin classAbstractSkillSource<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:AbstractSkillSourceReturns the path to the SKILL.md file for the given skill.- Specified by:
findSkillMdPathin classAbstractSkillSource<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:AbstractSkillSourceReturns the path to the resource for the given skill.- Specified by:
findResourcePathin classAbstractSkillSource<com.google.common.reflect.ClassPath.ResourceInfo>
-
openChannel
protected ReadableByteChannel openChannel(com.google.common.reflect.ClassPath.ResourceInfo path) throws IOException Description copied from class:AbstractSkillSourceOpens aInputStreamfor reading the content of the given path.- Specified by:
openChannelin classAbstractSkillSource<com.google.common.reflect.ClassPath.ResourceInfo>- Throws:
IOException
-