use crate::types::common::LettaId;
use serde::{Deserialize, Serialize};
use std::collections::HashMap;
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct TemplateItem {
pub name: String,
pub id: String,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct TemplatesListResponse {
pub templates: Vec<TemplateItem>,
#[serde(rename = "hasNextPage")]
pub has_next_page: bool,
}
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
pub struct CreateTemplateRequest {
#[serde(skip_serializing_if = "Option::is_none")]
pub project: Option<String>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct TemplatesCreateResponse {
pub template_name: String,
pub template_id: String,
}
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
pub struct VersionTemplateRequest {
#[serde(skip_serializing_if = "Option::is_none")]
pub migrate_deployed_agents: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub message: Option<String>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct MigrateAgentRequest {
pub to_template: String,
pub preserve_core_memories: bool,
#[serde(skip_serializing_if = "Option::is_none")]
pub variables: Option<HashMap<String, String>>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct TemplatesMigrateResponse {
pub agent: crate::types::agent::AgentState,
}
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
pub struct CreateAgentsFromTemplateRequest {
#[serde(skip_serializing_if = "Option::is_none")]
pub tags: Option<Vec<String>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub agent_name: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub memory_variables: Option<HashMap<String, String>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub tool_variables: Option<HashMap<String, String>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub identity_ids: Option<Vec<LettaId>>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct AgentsCreateResponse {
pub agents: Vec<crate::types::agent::AgentState>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct MemoryVariablesListResponse {
pub variables: HashMap<String, String>,
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_template_item_serialization() {
let item = TemplateItem {
name: "test-template".to_string(),
id: "template-123".to_string(),
};
let json = serde_json::to_string(&item).unwrap();
assert!(json.contains("test-template"));
assert!(json.contains("template-123"));
}
#[test]
fn test_migrate_request_serialization() {
let request = MigrateAgentRequest {
to_template: "my-template:v2".to_string(),
preserve_core_memories: true,
variables: None,
};
let json = serde_json::to_string(&request).unwrap();
assert!(json.contains("my-template:v2"));
assert!(json.contains("true"));
assert!(!json.contains("variables"));
}
}