Skip to main content

gproxy_protocol/protocol/claude/skills/
mod.rs

1use std::collections::BTreeMap;
2
3use serde::{Deserialize, Serialize};
4
5use super::common::{
6    AnthropicBetaHeaders, DeletedSkillObjectType, JsonObject, SkillObjectType, SkillSourceType,
7};
8
9mod versions;
10
11pub use versions::*;
12
13pub type SkillRequestHeaders = AnthropicBetaHeaders;
14
15/// Multipart form fields for `POST /v1/skills`.
16#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder)]
17#[non_exhaustive]
18pub struct CreateSkillRequestBody {
19    pub files: Vec<String>,
20    #[serde(skip_serializing_if = "Option::is_none")]
21    pub display_name: Option<String>,
22    #[serde(default, flatten, skip_serializing_if = "BTreeMap::is_empty")]
23    pub extra: JsonObject,
24}
25
26#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder)]
27#[non_exhaustive]
28pub struct SkillPath {
29    pub skill_id: String,
30}
31
32#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder)]
33#[non_exhaustive]
34pub struct ListSkillsQuery {
35    #[serde(skip_serializing_if = "Option::is_none")]
36    pub limit: Option<u64>,
37    #[serde(skip_serializing_if = "Option::is_none")]
38    pub page: Option<String>,
39    #[serde(skip_serializing_if = "Option::is_none")]
40    pub source: Option<SkillSourceType>,
41    #[serde(default, flatten, skip_serializing_if = "BTreeMap::is_empty")]
42    pub extra: JsonObject,
43}
44
45#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder)]
46#[non_exhaustive]
47pub struct SkillSource {
48    #[serde(rename = "type")]
49    pub type_: SkillSourceType,
50    #[serde(default, flatten, skip_serializing_if = "BTreeMap::is_empty")]
51    pub extra: JsonObject,
52}
53
54#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder)]
55#[non_exhaustive]
56pub struct SkillObject {
57    pub id: String,
58    pub created_at: String,
59    pub display_name: String,
60    pub latest_version_id: String,
61    pub source: SkillSource,
62    #[serde(rename = "type")]
63    pub type_: SkillObjectType,
64    pub updated_at: String,
65    #[serde(default, flatten, skip_serializing_if = "BTreeMap::is_empty")]
66    pub extra: JsonObject,
67}
68
69pub type CreateSkillResponseBody = SkillObject;
70pub type RetrieveSkillResponseBody = SkillObject;
71
72#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder)]
73#[non_exhaustive]
74pub struct ListSkillsResponseBody {
75    pub data: Vec<SkillObject>,
76    pub next_page: Option<String>,
77    #[serde(default, flatten, skip_serializing_if = "BTreeMap::is_empty")]
78    pub extra: JsonObject,
79}
80
81#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder)]
82#[non_exhaustive]
83pub struct DeleteSkillResponseBody {
84    pub id: String,
85    #[serde(rename = "type")]
86    pub type_: DeletedSkillObjectType,
87    #[serde(default, flatten, skip_serializing_if = "BTreeMap::is_empty")]
88    pub extra: JsonObject,
89}
90
91#[cfg(test)]
92mod tests {
93    use serde_json::json;
94
95    use super::*;
96
97    #[test]
98    fn decodes_ga_skill_resource_shape() {
99        let skill: SkillObject = serde_json::from_value(json!({
100            "id": "skill_123",
101            "created_at": "2026-08-19T00:00:00Z",
102            "display_name": "Release notes",
103            "latest_version_id": "skillver_456",
104            "source": {"type": "anthropic_example"},
105            "type": "skill",
106            "updated_at": "2026-08-19T01:00:00Z"
107        }))
108        .unwrap();
109
110        assert!(matches!(
111            skill.source.type_,
112            SkillSourceType::Known(super::super::common::SkillSourceTypeKnown::AnthropicExample)
113        ));
114    }
115}