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>, ctx: &RequestContext) -> Self {
39 Self {
40 artifact_type: "copy_paste_text".to_owned(),
41 content: content.into(),
42 title: None,
43 language: None,
44 metadata: ExecutionMetadata::with_request(ctx),
45 }
46 }
47
48 pub fn with_title(mut self, title: impl Into<String>) -> Self {
49 self.title = Some(title.into());
50 self
51 }
52
53 pub fn with_language(mut self, language: impl Into<String>) -> Self {
54 self.language = Some(language.into());
55 self
56 }
57
58 pub fn with_execution_id(mut self, id: impl Into<String>) -> Self {
59 self.metadata.execution_id = Some(id.into());
60 self
61 }
62
63 pub fn with_skill(
64 mut self,
65 skill_id: impl Into<SkillId>,
66 skill_name: impl Into<String>,
67 ) -> Self {
68 self.metadata.skill_id = Some(skill_id.into());
69 self.metadata.skill_name = Some(skill_name.into());
70 self
71 }
72}
73
74impl Artifact for CopyPasteTextArtifact {
75 fn artifact_type(&self) -> ArtifactType {
76 ArtifactType::CopyPasteText
77 }
78
79 fn to_schema(&self) -> JsonValue {
80 json!({
81 "type": "object",
82 "properties": {
83 "content": {
84 "type": "string",
85 "description": "Text content to be copied"
86 },
87 "title": {
88 "type": "string",
89 "description": "Optional title for the content"
90 },
91 "language": {
92 "type": "string",
93 "description": "Optional language for syntax highlighting"
94 }
95 },
96 "required": ["content"],
97 "x-artifact-type": "copy_paste_text"
98 })
99 }
100}