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