bamboo_agent/agent/skill/
mod.rs1pub mod context;
4pub mod store;
5pub mod types;
6
7pub use store::{SkillStore, SkillUpdate};
8pub use types::*;
9
10use std::collections::HashSet;
11use std::sync::Arc;
12
13#[derive(Clone)]
15pub struct SkillManager {
16 store: Arc<SkillStore>,
17}
18
19impl SkillManager {
20 pub fn new() -> Self {
22 Self {
23 store: Arc::new(SkillStore::default()),
24 }
25 }
26
27 pub fn with_config(config: SkillStoreConfig) -> Self {
29 Self {
30 store: Arc::new(SkillStore::new(config)),
31 }
32 }
33
34 pub async fn initialize(&self) -> SkillResult<()> {
36 self.store.initialize().await
37 }
38
39 pub fn store(&self) -> &SkillStore {
41 &self.store
42 }
43
44 pub async fn build_skill_context(&self, _chat_id: Option<&str>) -> String {
46 let skills = self.store.list_skills(None, true).await;
48 log::info!("Building skill context with {} skill(s)", skills.len());
49 context::build_skill_context(&skills)
50 }
51
52 pub async fn get_allowed_tools(&self, _chat_id: Option<&str>) -> Vec<String> {
54 let skills = self.store.list_skills(None, true).await;
56
57 let mut tools: Vec<String> = skills
58 .into_iter()
59 .flat_map(|skill| skill.tool_refs)
60 .collect::<HashSet<_>>()
61 .into_iter()
62 .collect();
63
64 tools.sort();
65 tools
66 }
67}
68
69impl Default for SkillManager {
70 fn default() -> Self {
71 Self::new()
72 }
73}