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