Skip to main content

argentor_skills/
skill.rs

1use argentor_core::{ArgentorResult, ToolCall, ToolResult};
2use argentor_security::{Capability, PermissionSet};
3use async_trait::async_trait;
4use serde::{Deserialize, Serialize};
5
6/// Metadata describing a skill's interface and required permissions.
7#[derive(Debug, Clone, Serialize, Deserialize)]
8pub struct SkillDescriptor {
9    /// Unique skill name.
10    pub name: String,
11    /// Human-readable description of the skill.
12    pub description: String,
13    /// JSON Schema describing the expected parameters.
14    pub parameters_schema: serde_json::Value,
15    /// Capabilities the skill needs to operate.
16    pub required_capabilities: Vec<Capability>,
17    /// Whether the agent runner must obtain human approval before executing this skill.
18    /// Defaults to `false`. Skills that delete data, send emails, or spend money should set this.
19    #[serde(default)]
20    pub requires_approval: bool,
21}
22
23/// Trait that all skills must implement — whether native Rust or WASM.
24#[async_trait]
25pub trait Skill: Send + Sync {
26    /// Return the skill's metadata descriptor.
27    fn descriptor(&self) -> &SkillDescriptor;
28
29    /// Execute the skill with the given tool call.
30    async fn execute(&self, call: ToolCall) -> ArgentorResult<ToolResult>;
31
32    /// Validate that the specific arguments in this tool call are permitted
33    /// by the given permission set. Override for skills that need argument-level checks.
34    /// Default: always returns Ok(()) (no argument-level validation).
35    fn validate_arguments(
36        &self,
37        _call: &ToolCall,
38        _permissions: &PermissionSet,
39    ) -> ArgentorResult<()> {
40        Ok(())
41    }
42}