adk_studio/schema/
tool.rs1use serde::{Deserialize, Serialize};
2use serde_json::Value;
3
4#[derive(Debug, Clone, Serialize, Deserialize)]
6pub struct ToolSchema {
7 #[serde(rename = "type")]
8 pub tool_type: ToolType,
9 #[serde(default)]
10 pub config: Value,
11 #[serde(default)]
12 pub description: String,
13}
14
15impl ToolSchema {
16 pub fn builtin(description: impl Into<String>) -> Self {
17 Self {
18 tool_type: ToolType::Builtin,
19 config: Value::Object(Default::default()),
20 description: description.into(),
21 }
22 }
23}
24
25#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
27#[serde(rename_all = "snake_case")]
28pub enum ToolType {
29 Builtin,
30 Mcp,
31 Custom,
32}
33
34#[derive(Debug, Clone, Serialize, Deserialize)]
36#[serde(tag = "type", rename_all = "snake_case")]
37pub enum ToolConfig {
38 Mcp(McpToolConfig),
39 Function(FunctionToolConfig),
40 Browser(BrowserToolConfig),
41}
42
43#[derive(Debug, Clone, Serialize, Deserialize)]
45pub struct McpToolConfig {
46 pub server_command: String,
47 #[serde(default)]
48 pub server_args: Vec<String>,
49 #[serde(default)]
50 pub tool_filter: Vec<String>,
51}
52
53#[derive(Debug, Clone, Serialize, Deserialize)]
55pub struct FunctionToolConfig {
56 pub name: String,
57 pub description: String,
58 #[serde(default)]
59 pub parameters: Vec<FunctionParameter>,
60 #[serde(default)]
61 pub code: String,
62}
63
64#[derive(Debug, Clone, Serialize, Deserialize)]
66pub struct FunctionParameter {
67 pub name: String,
68 pub param_type: ParamType,
69 #[serde(default)]
70 pub description: String,
71 #[serde(default)]
72 pub required: bool,
73}
74
75#[derive(Debug, Clone, Serialize, Deserialize)]
76#[serde(rename_all = "snake_case")]
77pub enum ParamType {
78 String,
79 Number,
80 Boolean,
81}
82
83#[derive(Debug, Clone, Serialize, Deserialize)]
85pub struct BrowserToolConfig {
86 #[serde(default = "default_headless")]
87 pub headless: bool,
88 #[serde(default = "default_timeout")]
89 pub timeout_ms: u64,
90}
91
92fn default_headless() -> bool {
93 true
94}
95fn default_timeout() -> u64 {
96 30000
97}
98
99pub mod builtins {
101 pub const GOOGLE_SEARCH: &str = "google_search";
102 pub const WEB_BROWSE: &str = "web_browse";
103 pub const CODE_EXEC: &str = "code_exec";
104 pub const FILE_READ: &str = "file_read";
105 pub const FILE_WRITE: &str = "file_write";
106}