Skip to main content

aidaemon_memory/
skills.rs

1//! Skills a host keeps in its database: drafts promoted from successful
2//! procedures, pending the owner's review, and the deprecated dynamic skills
3//! kept for migration compatibility.
4
5use async_trait::async_trait;
6use serde::{Deserialize, Serialize};
7
8use crate::Procedure;
9
10/// A dynamically added skill (stored in database).
11/// Deprecated: kept for migration compatibility. Use filesystem skills instead.
12#[derive(Debug, Clone, Serialize, Deserialize)]
13pub struct DynamicSkill {
14    pub id: i64,
15    pub name: String,
16    pub description: String,
17    pub triggers_json: String, // JSON array of trigger strings
18    pub body: String,
19    pub source: String, // "url", "inline", "auto", "registry"
20    pub source_url: Option<String>,
21    pub enabled: bool,
22    pub version: Option<String>,
23    pub created_at: String,
24    /// JSON-serialized `Vec<ResourceEntry>` for directory-based skills
25    #[serde(default = "default_empty_json")]
26    pub resources_json: String,
27}
28
29/// A skill draft created by auto-promotion, pending user review.
30#[derive(Debug, Clone, Serialize, Deserialize)]
31pub struct SkillDraft {
32    pub id: i64,
33    pub name: String,
34    pub description: String,
35    pub triggers_json: String,
36    pub body: String,
37    pub source_procedure: String,
38    pub status: String, // "pending", "approved", "dismissed"
39    pub created_at: String,
40}
41
42fn default_empty_json() -> String {
43    "[]".to_string()
44}
45
46/// Skills storage (deprecated dynamic skills + skill drafts).
47#[async_trait]
48pub trait SkillStore: Send + Sync {
49    /// Store a dynamically added skill.
50    /// Deprecated: use filesystem skills instead.
51    async fn add_dynamic_skill(&self, _skill: &DynamicSkill) -> anyhow::Result<i64> {
52        Ok(0)
53    }
54
55    /// Get all dynamic skills.
56    /// Deprecated: use filesystem skills instead.
57    async fn get_dynamic_skills(&self) -> anyhow::Result<Vec<DynamicSkill>> {
58        Ok(vec![])
59    }
60
61    /// Delete a dynamic skill by ID.
62    /// Deprecated: use filesystem skills instead.
63    async fn delete_dynamic_skill(&self, _id: i64) -> anyhow::Result<()> {
64        Ok(())
65    }
66
67    /// Update the enabled flag of a dynamic skill.
68    /// Deprecated: file existence = active, no enable/disable needed.
69    async fn update_dynamic_skill_enabled(&self, _id: i64, _enabled: bool) -> anyhow::Result<()> {
70        Ok(())
71    }
72
73    /// Get procedures eligible for skill promotion (success_count >= min_success, success rate >= min_rate).
74    async fn get_promotable_procedures(
75        &self,
76        _min_success: i32,
77        _min_rate: f32,
78    ) -> anyhow::Result<Vec<Procedure>> {
79        Ok(vec![])
80    }
81
82    /// Store a skill draft from auto-promotion. Returns the draft ID.
83    async fn add_skill_draft(&self, _draft: &SkillDraft) -> anyhow::Result<i64> {
84        Ok(0)
85    }
86
87    /// Get all pending skill drafts.
88    async fn get_pending_skill_drafts(&self) -> anyhow::Result<Vec<SkillDraft>> {
89        Ok(vec![])
90    }
91
92    /// Get a skill draft by ID.
93    async fn get_skill_draft(&self, _id: i64) -> anyhow::Result<Option<SkillDraft>> {
94        Ok(None)
95    }
96
97    /// Update a skill draft's status ("approved" or "dismissed").
98    async fn update_skill_draft_status(&self, _id: i64, _status: &str) -> anyhow::Result<()> {
99        Ok(())
100    }
101
102    /// Check if any draft record already exists for a given procedure name
103    /// (pending, approved, or dismissed).
104    async fn skill_draft_exists_for_procedure(
105        &self,
106        _procedure_name: &str,
107    ) -> anyhow::Result<bool> {
108        Ok(false)
109    }
110}