pub struct SkillCatalog { /* private fields */ }skills only.Expand description
The skills found in the configured directories, and what was noticed on the way.
Cheap to clone: the skills are shared. Built once, at start-up, by
discover; it does not change afterwards, so the prompt
and the tools’ schemas stay what the model was told. To pick up changed
files, discover again and build a new executor.
use a2a_protocol_server::skills::{SkillCatalog, SkillSource, SkillsConfig};
let catalog = SkillCatalog::discover(
&SkillsConfig::new().with_source(SkillSource::operator("/etc/my-agent/skills")),
);
for problem in catalog.diagnostics() {
eprintln!("{problem}");
}
println!("{} skills", catalog.len());Implementations§
Source§impl SkillCatalog
impl SkillCatalog
Sourcepub fn discover(config: &SkillsConfig) -> SkillCatalog
pub fn discover(config: &SkillsConfig) -> SkillCatalog
Reads the skills config names.
Never fails and never panics: a directory that cannot be read, a
SKILL.md that is malformed, a name that is taken, are each a
SkillDiagnostic and the rest is still loaded. It reads files, so
call it at start-up, or from a blocking task.
Sourcepub fn skills(&self) -> &[Skill]
pub fn skills(&self) -> &[Skill]
The skills, operator directories first, each directory’s in name order.
Sourcepub fn diagnostics(&self) -> &[SkillDiagnostic]
pub fn diagnostics(&self) -> &[SkillDiagnostic]
What discovery noticed, in the order it noticed it. Log it:
SkillDiagnostic is Display, and a skill that is missing from the
catalog is explained here and nowhere else.
Sourcepub fn prompt(&self) -> Option<String>
pub fn prompt(&self) -> Option<String>
The catalog as the model is told it: a short instruction and each
skill’s name and description, in the form the specification’s client
guide shows. None when there are no skills, because an empty catalog
would only confuse the model.
A description is on one line, shortened to the configured length,
and XML-escaped, so it cannot close the element it is in. A project
skill is marked <origin>project</origin>.
Sourcepub fn tools(&self) -> Vec<Arc<dyn Tool>>
pub fn tools(&self) -> Vec<Arc<dyn Tool>>
The tools that serve the catalog: activate_skill, and
read_skill_file when some skill bundles files. None at all when the
catalog is empty, because a tool whose name has no valid value
would confuse the model.
ToolLoopExecutor::with_skills
adds these and the prompt; this is for a loop run
without it.
Sourcepub fn agent_skills(&self) -> Vec<AgentSkill>
pub fn agent_skills(&self) -> Vec<AgentSkill>
Each skill as an AgentSkill for the agent card, which is public:
id and name are the skill’s name, description is its
description whole and verbatim, and the one tag is
AGENT_SKILL_TAG. Nothing is advertised unless the card is built
from this, and a skill’s description is not necessarily meant to be
public.
use a2a_protocol_types::agent_card::{AgentCard, AgentInterface};
let mut card = AgentCard::new("agent", "1.0.0", AgentInterface::jsonrpc("http://127.0.0.1:3000"));
for skill in catalog.agent_skills() {
card = card.with_skill(skill);
}Trait Implementations§
Source§impl Clone for SkillCatalog
impl Clone for SkillCatalog
Source§fn clone(&self) -> SkillCatalog
fn clone(&self) -> SkillCatalog
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Forget for SkillCatalog
impl Freeze for SkillCatalog
impl Move for SkillCatalog
impl RefUnwindSafe for SkillCatalog
impl Send for SkillCatalog
impl Sync for SkillCatalog
impl Unpin for SkillCatalog
impl UnsafeUnpin for SkillCatalog
impl UnwindSafe for SkillCatalog
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request§impl<L> LayerExt<L> for L
impl<L> LayerExt<L> for L
§fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
Layered].