distri_types/configuration/
package.rs1use crate::ToolDefinition;
2use crate::agent::StandardDefinition;
3use crate::configuration::manifest::DistriServerConfig;
4use serde::{Deserialize, Serialize};
5use std::path::PathBuf;
6
7#[derive(Debug, Clone, Serialize, Deserialize)]
9pub struct PluginToolDefinition {
10 pub name: String,
11 pub package_name: String,
12 pub description: String,
13 #[serde(default)]
14 pub parameters: serde_json::Value,
15 #[serde(default, skip_serializing_if = "Option::is_none")]
16 pub auth: Option<crate::auth::AuthRequirement>,
17}
18
19#[derive(Debug, Clone, Serialize, Deserialize, Default)]
21pub struct AgentCloudMetadata {
22 #[serde(default, skip_serializing_if = "Option::is_none")]
23 pub id: Option<uuid::Uuid>,
24 #[serde(default, skip_serializing_if = "Option::is_none")]
25 pub published: Option<bool>,
26 #[serde(default, skip_serializing_if = "Option::is_none")]
27 pub published_at: Option<chrono::DateTime<chrono::Utc>>,
28 #[serde(default, skip_serializing_if = "Option::is_none")]
29 pub is_owner: Option<bool>,
30}
31
32#[derive(Debug, Clone, Serialize, Deserialize)]
33pub struct AgentConfigWithTools {
34 #[serde(flatten)]
35 pub agent: AgentConfig,
36 #[serde(default, skip_serializing_if = "Vec::is_empty")]
37 pub resolved_tools: Vec<ToolDefinition>,
38 #[serde(default, skip_serializing_if = "Option::is_none")]
39 pub markdown: Option<String>,
40 #[serde(flatten, default)]
42 pub cloud: AgentCloudMetadata,
43}
44
45#[derive(Debug, Clone, Serialize, Deserialize)]
47#[serde(tag = "agent_type", rename_all = "snake_case")]
48pub enum AgentConfig {
49 StandardAgent(StandardDefinition),
51}
52
53impl AgentConfig {
54 pub fn get_name(&self) -> &str {
56 match self {
57 AgentConfig::StandardAgent(def) => &def.name,
58 }
59 }
60
61 pub fn get_definition(&self) -> &StandardDefinition {
62 match self {
63 AgentConfig::StandardAgent(def) => &def,
64 }
65 }
66
67 pub fn get_description(&self) -> &str {
69 match self {
70 AgentConfig::StandardAgent(def) => &def.description,
71 }
72 }
73
74 pub fn validate(&self) -> anyhow::Result<()> {
76 match self {
77 AgentConfig::StandardAgent(def) => def.validate(),
78 }
79 }
80
81 pub fn get_working_directory(
83 &self,
84 package_config: Option<&DistriServerConfig>,
85 ) -> anyhow::Result<std::path::PathBuf> {
86 if let Some(config) = package_config {
88 return config.get_working_directory();
89 }
90
91 if let Ok(distri_home) = std::env::var("DISTRI_HOME") {
93 return Ok(std::path::PathBuf::from(distri_home));
94 }
95
96 std::env::current_dir()
98 .map_err(|e| anyhow::anyhow!("Failed to get current directory: {}", e))
99 }
100}
101
102#[derive(Debug, Clone, Serialize, Deserialize)]
104pub struct PluginAgentDefinition {
105 pub name: String,
106 pub package_name: String,
107 pub description: String,
108 pub file_path: PathBuf,
109 pub agent_config: AgentConfig,
111}
112
113#[derive(Debug, Clone, Serialize, Deserialize)]
115pub struct PluginArtifact {
116 pub name: String,
117 pub path: PathBuf,
118 pub configuration: crate::configuration::manifest::DistriServerConfig,
119 pub tools: Vec<PluginToolDefinition>,
120 pub agents: Vec<PluginAgentDefinition>,
121}