rs_agent/
types.rs

1use serde::{Deserialize, Serialize};
2use std::collections::HashMap;
3
4/// Tool specification describing how an agent presents a tool to the model
5#[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/// Tool request captures an invocation request
15#[derive(Debug, Clone)]
16pub struct ToolRequest {
17    pub session_id: String,
18    pub arguments: HashMap<String, serde_json::Value>,
19}
20
21/// Tool response represents the structured response from a tool
22#[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/// Message role in a conversation
30#[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/// Message in a conversation
40#[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/// File attachment
49#[derive(Debug, Clone, Serialize, Deserialize)]
50pub struct File {
51    pub mime_type: String,
52    pub data: Vec<u8>,
53}
54
55/// Generation response from a model
56#[derive(Debug, Clone, Serialize, Deserialize)]
57pub struct GenerationResponse {
58    pub content: String,
59    pub metadata: Option<HashMap<String, String>>,
60}
61
62/// Configuration options for creating an agent
63#[derive(Debug, Clone)]
64pub struct AgentOptions {
65    pub system_prompt: Option<String>,
66    pub context_limit: Option<usize>,
67}
68
69impl Default for AgentOptions {
70    fn default() -> Self {
71        Self {
72            system_prompt: None,
73            context_limit: Some(8192),
74        }
75    }
76}