Skip to main content

brainos_cortex/actions/
tooling.rs

1/// Tool definition for LLM function calling.
2#[derive(Debug, Clone, serde::Serialize)]
3pub struct ToolDefinition {
4    pub name: String,
5    pub description: String,
6    pub parameters: serde_json::Value,
7}
8
9/// Get available tools as LLM function definitions.
10pub fn get_available_tools() -> Vec<ToolDefinition> {
11    vec![
12        ToolDefinition {
13            name: "execute_command".to_string(),
14            description: "Execute a sandboxed shell command".to_string(),
15            parameters: serde_json::json!({
16                "type": "object",
17                "properties": {
18                    "command": {
19                        "type": "string",
20                        "description": "The command to execute"
21                    },
22                    "args": {
23                        "type": "array",
24                        "items": {"type": "string"},
25                        "description": "Command arguments"
26                    }
27                },
28                "required": ["command"]
29            }),
30        },
31        ToolDefinition {
32            name: "web_search".to_string(),
33            description: "Search the web for information".to_string(),
34            parameters: serde_json::json!({
35                "type": "object",
36                "properties": {
37                    "query": {
38                        "type": "string",
39                        "description": "The search query"
40                    }
41                },
42                "required": ["query"]
43            }),
44        },
45        ToolDefinition {
46            name: "store_fact".to_string(),
47            description: "Store a fact in memory".to_string(),
48            parameters: serde_json::json!({
49                "type": "object",
50                "properties": {
51                    "subject": {"type": "string"},
52                    "predicate": {"type": "string"},
53                    "object": {"type": "string"}
54                },
55                "required": ["subject", "predicate", "object"]
56            }),
57        },
58        ToolDefinition {
59            name: "recall".to_string(),
60            description: "Search memory for relevant information".to_string(),
61            parameters: serde_json::json!({
62                "type": "object",
63                "properties": {
64                    "query": {
65                        "type": "string",
66                        "description": "What to search for"
67                    }
68                },
69                "required": ["query"]
70            }),
71        },
72    ]
73}