1use serde::{Deserialize, Serialize};
2use std::collections::HashMap;
3
4#[derive(Debug, Clone, Serialize, Deserialize)]
6pub struct ToolSpec {
7 pub name: String,
8 pub description: String,
9 pub input_schema: serde_json::Value,
10 #[serde(skip_serializing_if = "Option::is_none")]
11 pub examples: Option<Vec<serde_json::Value>>,
12}
13
14#[derive(Debug, Clone)]
16pub struct ToolRequest {
17 pub session_id: String,
18 pub arguments: HashMap<String, serde_json::Value>,
19}
20
21#[derive(Debug, Clone, Serialize, Deserialize)]
23pub struct ToolResponse {
24 pub content: String,
25 #[serde(skip_serializing_if = "Option::is_none")]
26 pub metadata: Option<HashMap<String, String>>,
27}
28
29#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
31#[serde(rename_all = "lowercase")]
32pub enum Role {
33 System,
34 User,
35 Assistant,
36 Tool,
37}
38
39#[derive(Debug, Clone, Serialize, Deserialize)]
41pub struct Message {
42 pub role: Role,
43 pub content: String,
44 #[serde(skip_serializing_if = "Option::is_none")]
45 pub metadata: Option<HashMap<String, String>>,
46}
47
48#[derive(Debug, Clone, Serialize, Deserialize)]
50pub struct File {
51 pub mime_type: String,
52 pub data: Vec<u8>,
53}
54
55#[derive(Debug, Clone, Serialize, Deserialize)]
57pub struct GenerationResponse {
58 pub content: String,
59 pub metadata: Option<HashMap<String, String>>,
60}
61
62#[derive(Debug, Clone, Serialize, Deserialize)]
64pub struct GenerationChunk {
65 pub content: String,
66 pub metadata: Option<HashMap<String, String>>,
68}
69
70#[derive(Debug, Clone)]
72pub struct AgentOptions {
73 pub system_prompt: Option<String>,
74 pub context_limit: Option<usize>,
75}
76
77impl Default for AgentOptions {
78 fn default() -> Self {
79 Self {
80 system_prompt: None,
81 context_limit: Some(8192),
82 }
83 }
84}
85
86use crate::error::Result;
91use crate::memory::MemoryRecord;
92use async_trait::async_trait;
93use chrono::{DateTime, Utc};
94use std::sync::Arc;
95
96#[async_trait]
98pub trait SubAgent: Send + Sync {
99 fn name(&self) -> String;
101
102 fn description(&self) -> String;
104
105 async fn run(&self, input: String) -> Result<String>;
107}
108
109pub trait SubAgentDirectory: Send + Sync {
111 fn register(&self, subagent: Arc<dyn SubAgent>) -> Result<()>;
113
114 fn lookup(&self, name: &str) -> Option<Arc<dyn SubAgent>>;
116
117 fn all(&self) -> Vec<Arc<dyn SubAgent>>;
119}
120
121#[derive(Debug, Clone, Serialize, Deserialize)]
123pub struct AgentState {
124 pub system_prompt: String,
125 pub short_term: Vec<MemoryRecord>,
126 #[serde(skip_serializing_if = "Option::is_none")]
127 pub joined_spaces: Option<Vec<String>>,
128 pub timestamp: DateTime<Utc>,
129}