pub struct AgentSkill { /* private fields */ }Expand description
A program’s skill on the user’s machine.
use agent_skill_installer::{AgentSkill, Program, Skill};
let skill = Skill::new("mytool", "Use mytool to do the thing.", "# mytool\n")?;
let program = Program::new("mytool", "1.2.0")?;
let agent = AgentSkill::new(skill, program, "/data/mytool/skill-consent")?;
agent.update()?; // at start, without asking
if let Some(offer) = agent.offer()? {
// Ask once in your own surface, naming offer.steps().
offer.accept()?; // or offer.decline()?
}Implementations§
Source§impl AgentSkill
impl AgentSkill
Sourcepub fn new(
skill: Skill,
program: Program,
consent_file: impl Into<PathBuf>,
) -> Result<Self, Error>
pub fn new( skill: Skill, program: Program, consent_file: impl Into<PathBuf>, ) -> Result<Self, Error>
The skill for the user running the program, with the built-in tools.
consent_file is where the places the user declined are kept; the
program’s own data directory is the natural home for it.
§Errors
Returns Error::NoHome when the process has no home directory.
Sourcepub fn with_environment(self, env: Environment) -> Self
pub fn with_environment(self, env: Environment) -> Self
The same, looking at another environment: a test’s temporary home.
Sourcepub fn with_catalog(self, catalog: Catalog) -> Self
pub fn with_catalog(self, catalog: Catalog) -> Self
The same, with a catalog the program extended or replaced.
Sourcepub const fn catalog(&self) -> &Catalog
pub const fn catalog(&self) -> &Catalog
The tools and folders it knows, for naming them to people.
Sourcepub const fn installer(&self) -> Installer<'_>
pub const fn installer(&self) -> Installer<'_>
The installer underneath, for a program that decides place by place.
Sourcepub fn status(&self) -> Result<Assessment, Error>
pub fn status(&self) -> Result<Assessment, Error>
Every place and what would happen there. Writes nothing.
§Errors
Returns an error when the answers cannot be read or no plan can be made.
Sourcepub fn update(&self) -> Result<Vec<Outcome>, Error>
pub fn update(&self) -> Result<Vec<Outcome>, Error>
Bring every copy this program installed and nobody changed up to the running version. Asks nothing and installs nothing new; meant for every start of the program.
§Errors
Returns an error when no plan can be made.
Sourcepub fn offer(&self) -> Result<Option<Offer<'_>>, Error>
pub fn offer(&self) -> Result<Option<Offer<'_>>, Error>
The question to ask, when a place exists nobody has decided on.
§Errors
Returns an error when the answers cannot be read or no plan can be made.