systemprompt_models/artifacts/copy_paste_text/
mod.rs

1use crate::artifacts::metadata::ExecutionMetadata;
2use crate::artifacts::traits::Artifact;
3use crate::artifacts::types::ArtifactType;
4use crate::execution::context::RequestContext;
5use schemars::JsonSchema;
6use serde::{Deserialize, Serialize};
7use serde_json::{json, Value as JsonValue};
8use systemprompt_identifiers::SkillId;
9
10fn default_artifact_type() -> String {
11    "copy_paste_text".to_string()
12}
13
14#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
15pub struct CopyPasteTextArtifact {
16    #[serde(rename = "x-artifact-type")]
17    #[serde(default = "default_artifact_type")]
18    pub artifact_type: String,
19    pub content: String,
20    #[serde(skip_serializing_if = "Option::is_none")]
21    pub title: Option<String>,
22    #[serde(skip_serializing_if = "Option::is_none")]
23    pub language: Option<String>,
24    #[serde(skip)]
25    #[schemars(skip)]
26    metadata: ExecutionMetadata,
27}
28
29impl CopyPasteTextArtifact {
30    pub fn new(content: impl Into<String>, ctx: &RequestContext) -> Self {
31        Self {
32            artifact_type: "copy_paste_text".to_string(),
33            content: content.into(),
34            title: None,
35            language: None,
36            metadata: ExecutionMetadata::with_request(ctx),
37        }
38    }
39
40    pub fn with_title(mut self, title: impl Into<String>) -> Self {
41        self.title = Some(title.into());
42        self
43    }
44
45    pub fn with_language(mut self, language: impl Into<String>) -> Self {
46        self.language = Some(language.into());
47        self
48    }
49
50    pub fn with_execution_id(mut self, id: impl Into<String>) -> Self {
51        self.metadata.execution_id = Some(id.into());
52        self
53    }
54
55    pub fn with_skill(
56        mut self,
57        skill_id: impl Into<SkillId>,
58        skill_name: impl Into<String>,
59    ) -> Self {
60        self.metadata.skill_id = Some(skill_id.into());
61        self.metadata.skill_name = Some(skill_name.into());
62        self
63    }
64}
65
66impl Artifact for CopyPasteTextArtifact {
67    fn artifact_type(&self) -> ArtifactType {
68        ArtifactType::CopyPasteText
69    }
70
71    fn to_schema(&self) -> JsonValue {
72        json!({
73            "type": "object",
74            "properties": {
75                "content": {
76                    "type": "string",
77                    "description": "Text content to be copied"
78                },
79                "title": {
80                    "type": "string",
81                    "description": "Optional title for the content"
82                },
83                "language": {
84                    "type": "string",
85                    "description": "Optional language for syntax highlighting"
86                }
87            },
88            "required": ["content"],
89            "x-artifact-type": "copy_paste_text"
90        })
91    }
92}