use serde::{Deserialize, Serialize};
use std::collections::HashMap;
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ToolSpec {
pub name: String,
pub description: String,
pub input_schema: serde_json::Value,
#[serde(skip_serializing_if = "Option::is_none")]
pub examples: Option<Vec<serde_json::Value>>,
}
#[derive(Debug, Clone)]
pub struct ToolRequest {
pub session_id: String,
pub arguments: HashMap<String, serde_json::Value>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ToolResponse {
pub content: String,
#[serde(skip_serializing_if = "Option::is_none")]
pub metadata: Option<HashMap<String, String>>,
}
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
#[serde(rename_all = "lowercase")]
pub enum Role {
System,
User,
Assistant,
Tool,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Message {
pub role: Role,
pub content: String,
#[serde(skip_serializing_if = "Option::is_none")]
pub metadata: Option<HashMap<String, String>>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct File {
pub mime_type: String,
pub data: Vec<u8>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct GenerationResponse {
pub content: String,
pub metadata: Option<HashMap<String, String>>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct GenerationChunk {
pub content: String,
pub metadata: Option<HashMap<String, String>>,
}
#[derive(Debug, Clone)]
pub struct AgentOptions {
pub system_prompt: Option<String>,
pub context_limit: Option<usize>,
}
impl Default for AgentOptions {
fn default() -> Self {
Self {
system_prompt: None,
context_limit: Some(8192),
}
}
}
use crate::error::Result;
use crate::memory::MemoryRecord;
use async_trait::async_trait;
use chrono::{DateTime, Utc};
use std::sync::Arc;
#[async_trait]
pub trait SubAgent: Send + Sync {
fn name(&self) -> String;
fn description(&self) -> String;
async fn run(&self, input: String) -> Result<String>;
}
pub trait SubAgentDirectory: Send + Sync {
fn register(&self, subagent: Arc<dyn SubAgent>) -> Result<()>;
fn lookup(&self, name: &str) -> Option<Arc<dyn SubAgent>>;
fn all(&self) -> Vec<Arc<dyn SubAgent>>;
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct AgentState {
pub system_prompt: String,
pub short_term: Vec<MemoryRecord>,
#[serde(skip_serializing_if = "Option::is_none")]
pub joined_spaces: Option<Vec<String>>,
pub timestamp: DateTime<Utc>,
}