systemprompt_traits/
managed_resources.rs1use async_trait::async_trait;
14use std::sync::Arc;
15use systemprompt_identifiers::{SkillId, UserId};
16
17#[derive(Debug, Clone, PartialEq, Eq)]
18pub struct ResolvedManagedSkill {
19 pub id: SkillId,
20 pub name: String,
21 pub description: String,
22 pub instructions: String,
23}
24
25#[derive(Debug, Clone, Copy, PartialEq, Eq)]
26pub enum WithheldReason {
27 NeverAdopted,
28 NotGranted,
29 Withdrawn,
30}
31
32impl WithheldReason {
33 #[must_use]
34 pub const fn as_str(self) -> &'static str {
35 match self {
36 Self::NotGranted => "not granted",
37 Self::NeverAdopted => "never adopted",
38 Self::Withdrawn => "withdrawn",
39 }
40 }
41}
42
43#[derive(Debug, Clone, PartialEq, Eq)]
44pub enum SkillResolution {
45 NotManaged,
46 Published(ResolvedManagedSkill),
47 Withheld(WithheldReason),
48}
49
50#[derive(Debug, thiserror::Error)]
51pub enum ManagedSkillResolverError {
52 #[error("managed skill `{key}` failed integrity verification")]
53 Integrity { key: String },
54 #[error("managed skill resolver unavailable: {0}")]
55 Unavailable(String),
56}
57
58#[async_trait]
62pub trait ManagedSkillResolver: Send + Sync + std::fmt::Debug {
63 async fn resolve_skill(
64 &self,
65 owner: &UserId,
66 key: &str,
67 ) -> Result<SkillResolution, ManagedSkillResolverError>;
68}
69
70pub type DynManagedSkillResolver = Arc<dyn ManagedSkillResolver>;