gproxy_protocol/protocol/claude/common/blocks/
response.rs1use serde::{Deserialize, Serialize};
2
3use super::super::server_tools::ResponseWebSearchToolResultContent;
4use super::super::{Caller, Citation, JsonObject, ServerToolUseName, StringOrArray};
5use super::{
6 CompactionBlockType, ContainerUploadBlockType, ServerToolUseBlockType, TextBlockType,
7 ToolUseBlockType, WebSearchResultBlockType, WebSearchToolResultBlockType,
8};
9
10#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
11pub struct ResponseTextBlock {
12 #[serde(skip_serializing_if = "Option::is_none")]
13 pub citations: Option<Vec<Citation>>,
14 pub text: String,
15 #[serde(rename = "type")]
16 pub type_: TextBlockType,
17 #[serde(default, flatten, skip_serializing_if = "JsonObject::is_empty")]
18 pub extra: JsonObject,
19}
20
21#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
22pub struct ResponseToolUseBlock {
23 pub id: String,
24 pub input: JsonObject,
25 pub name: String,
26 #[serde(rename = "type")]
27 pub type_: ToolUseBlockType,
28 #[serde(skip_serializing_if = "Option::is_none")]
29 pub caller: Option<Caller>,
30 #[serde(default, flatten, skip_serializing_if = "JsonObject::is_empty")]
31 pub extra: JsonObject,
32}
33
34#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
35pub struct ResponseServerToolUseBlock {
36 pub id: String,
37 pub input: JsonObject,
38 pub name: ServerToolUseName,
39 #[serde(rename = "type")]
40 pub type_: ServerToolUseBlockType,
41 #[serde(skip_serializing_if = "Option::is_none")]
42 pub caller: Option<Caller>,
43 #[serde(default, flatten, skip_serializing_if = "JsonObject::is_empty")]
44 pub extra: JsonObject,
45}
46
47#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
48pub struct ResponseWebSearchToolResultBlock {
49 pub content: ResponseWebSearchToolResultContent,
50 pub tool_use_id: String,
51 #[serde(rename = "type")]
52 pub type_: WebSearchToolResultBlockType,
53 #[serde(skip_serializing_if = "Option::is_none")]
54 pub caller: Option<Caller>,
55 #[serde(default, flatten, skip_serializing_if = "JsonObject::is_empty")]
56 pub extra: JsonObject,
57}
58
59#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
60pub struct ResponseWebSearchResultBlock {
61 pub encrypted_content: String,
62 pub page_age: Option<String>,
63 pub title: String,
64 #[serde(rename = "type")]
65 pub type_: WebSearchResultBlockType,
66 pub url: String,
67 #[serde(default, flatten, skip_serializing_if = "JsonObject::is_empty")]
68 pub extra: JsonObject,
69}
70
71#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
72pub struct ResponseToolReferenceBlock {
73 pub tool_name: String,
74 #[serde(rename = "type")]
75 pub type_: ResponseToolReferenceBlockType,
76 #[serde(default, flatten, skip_serializing_if = "JsonObject::is_empty")]
77 pub extra: JsonObject,
78}
79
80#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
81pub enum ResponseToolReferenceBlockType {
82 #[serde(rename = "tool_reference")]
83 ToolReference,
84}
85
86#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
87pub struct ResponseMcpToolUseBlock {
88 pub id: String,
89 pub input: JsonObject,
90 pub name: String,
91 pub server_name: String,
92 #[serde(rename = "type")]
93 pub type_: ResponseMcpToolUseBlockType,
94 #[serde(default, flatten, skip_serializing_if = "JsonObject::is_empty")]
95 pub extra: JsonObject,
96}
97
98#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
99pub enum ResponseMcpToolUseBlockType {
100 #[serde(rename = "mcp_tool_use")]
101 McpToolUse,
102}
103
104#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
105pub struct ResponseMcpToolResultBlock {
106 pub content: ResponseMcpToolResultContent,
107 pub is_error: bool,
108 pub tool_use_id: String,
109 #[serde(rename = "type")]
110 pub type_: ResponseMcpToolResultBlockType,
111 #[serde(default, flatten, skip_serializing_if = "JsonObject::is_empty")]
112 pub extra: JsonObject,
113}
114
115#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
116pub enum ResponseMcpToolResultBlockType {
117 #[serde(rename = "mcp_tool_result")]
118 McpToolResult,
119}
120
121pub type ResponseMcpToolResultContent = StringOrArray<ResponseTextBlock>;
122
123#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
124pub struct ResponseContainerUploadBlock {
125 pub file_id: String,
126 #[serde(rename = "type")]
127 pub type_: ContainerUploadBlockType,
128 #[serde(default, flatten, skip_serializing_if = "JsonObject::is_empty")]
129 pub extra: JsonObject,
130}
131
132#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
133pub struct ResponseCompactionBlock {
134 pub content: Option<String>,
135 pub encrypted_content: String,
136 #[serde(rename = "type")]
137 pub type_: CompactionBlockType,
138 #[serde(default, flatten, skip_serializing_if = "JsonObject::is_empty")]
139 pub extra: JsonObject,
140}