skill_runtime/
types.rs

1use serde::{Deserialize, Serialize};
2use std::collections::HashMap;
3
4/// Metadata about a skill
5#[derive(Debug, Clone, Serialize, Deserialize)]
6pub struct SkillMetadata {
7    pub name: String,
8    pub version: String,
9    pub description: String,
10    pub author: String,
11    pub repository: Option<String>,
12    pub license: Option<String>,
13}
14
15/// Definition of a tool provided by a skill
16#[derive(Debug, Clone, Serialize, Deserialize)]
17pub struct ToolDefinition {
18    pub name: String,
19    pub description: String,
20    pub parameters: Vec<Parameter>,
21    pub streaming: bool,
22}
23
24/// Parameter definition for a tool
25#[derive(Debug, Clone, Serialize, Deserialize)]
26pub struct Parameter {
27    pub name: String,
28    #[serde(rename = "type")]
29    pub param_type: ParameterType,
30    pub description: String,
31    pub required: bool,
32    pub default_value: Option<String>,
33}
34
35/// Supported parameter types
36#[derive(Debug, Clone, Serialize, Deserialize)]
37#[serde(rename_all = "lowercase")]
38pub enum ParameterType {
39    String,
40    Number,
41    Boolean,
42    File,
43    Json,
44    Array,
45}
46
47/// Result of tool execution
48#[derive(Debug, Clone, Serialize, Deserialize)]
49pub struct ExecutionResult {
50    pub success: bool,
51    pub output: String,
52    pub error_message: Option<String>,
53    pub metadata: Option<HashMap<String, String>>,
54}
55
56/// Chunk of streaming output
57#[derive(Debug, Clone, Serialize, Deserialize)]
58pub struct StreamChunk {
59    pub chunk_type: StreamChunkType,
60    pub data: String,
61}
62
63/// Type of stream chunk
64#[derive(Debug, Clone, Serialize, Deserialize)]
65#[serde(rename_all = "lowercase")]
66pub enum StreamChunkType {
67    Stdout,
68    Stderr,
69    Progress,
70    Metadata,
71}
72
73/// Configuration key-value pair
74#[derive(Debug, Clone, Serialize, Deserialize)]
75pub struct ConfigValue {
76    pub key: String,
77    pub value: String,
78    pub secret: bool,
79}
80
81/// Skill dependency declaration
82#[derive(Debug, Clone, Serialize, Deserialize)]
83pub struct Dependency {
84    pub skill_name: String,
85    pub version_constraint: String,
86    pub optional: bool,
87}
88
89/// Log level for host logging
90#[derive(Debug, Clone, Copy, Serialize, Deserialize)]
91#[serde(rename_all = "lowercase")]
92pub enum LogLevel {
93    Trace,
94    Debug,
95    Info,
96    Warn,
97    Error,
98}
99
100impl From<LogLevel> for tracing::Level {
101    fn from(level: LogLevel) -> Self {
102        match level {
103            LogLevel::Trace => tracing::Level::TRACE,
104            LogLevel::Debug => tracing::Level::DEBUG,
105            LogLevel::Info => tracing::Level::INFO,
106            LogLevel::Warn => tracing::Level::WARN,
107            LogLevel::Error => tracing::Level::ERROR,
108        }
109    }
110}