1use serde::{Deserialize, Serialize};
2use serde_json::Value;
3
4#[derive(Serialize, Deserialize, Debug, Clone)]
5pub struct ToolDefinition {
6 pub name: String,
7 pub desc: String,
8 pub arguments: serde_json::Value,
9}
10
11#[derive(Debug, Serialize, Deserialize, Clone)]
12pub struct Message {
13 pub role: Role,
14 pub blocks: Vec<ContentBlock>,
15}
16
17impl Message {
18 pub fn text(role: Role, text: impl Into<String>) -> Self {
19 Self {
20 role,
21 blocks: vec![ContentBlock::Text { text: text.into() }],
22 }
23 }
24}
25
26#[derive(Debug, Serialize, Deserialize, Clone)]
27pub enum ContentBlock {
28 Text {
29 text: String,
30 },
31 Thinking {
32 text: String,
33 },
34 ToolUse {
35 id: String,
36 name: String,
37 input: serde_json::Value,
38 },
39 ToolResult {
40 tool_use_id: String,
41 content: Vec<ContentBlock>,
42 is_error: bool,
43 },
44}
45
46#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq)]
47pub enum Role {
48 User,
49 Assistant,
50 Tool,
51 System,
52}
53
54#[derive(Debug, Serialize, Deserialize, Clone)]
55pub struct ToolCall {
56 pub call_id: String,
57 pub tool_name: String,
58 pub arguments: Value,
59}
60
61#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
66pub struct UserInteraction {
67 pub kind: String,
68 pub payload: Value,
69}