use std::collections::HashMap;
use std::path::PathBuf;
use serde::{Deserialize, Serialize};
use astrid_core::ConnectorProfile;
use astrid_core::identity::FrontendType;
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct CapsuleManifest {
pub package: PackageDef,
pub component: Option<ComponentDef>,
#[serde(default)]
pub dependencies: HashMap<String, String>,
#[serde(default)]
pub capabilities: CapabilitiesDef,
#[serde(default)]
pub env: HashMap<String, EnvDef>,
#[serde(default, rename = "context_file")]
pub context_files: Vec<ContextFileDef>,
#[serde(default, rename = "command")]
pub commands: Vec<CommandDef>,
#[serde(default, rename = "mcp_server")]
pub mcp_servers: Vec<McpServerDef>,
#[serde(default, rename = "skill")]
pub skills: Vec<SkillDef>,
#[serde(default, rename = "uplink")]
pub uplinks: Vec<UplinkDef>,
#[serde(default, rename = "llm_provider")]
pub llm_providers: Vec<LlmProviderDef>,
#[serde(default, rename = "interceptor")]
pub interceptors: Vec<InterceptorDef>,
#[serde(default, rename = "cron")]
pub cron_jobs: Vec<CronDef>,
#[serde(default, rename = "tool")]
pub tools: Vec<ToolDef>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct PackageDef {
pub name: String,
pub version: String,
pub description: Option<String>,
#[serde(default)]
pub authors: Vec<String>,
pub repository: Option<String>,
pub homepage: Option<String>,
pub documentation: Option<String>,
pub license: Option<String>,
#[serde(rename = "license-file")]
pub license_file: Option<PathBuf>,
pub readme: Option<PathBuf>,
#[serde(default)]
pub keywords: Vec<String>,
#[serde(default)]
pub categories: Vec<String>,
#[serde(rename = "astrid-version")]
pub astrid_version: Option<String>,
pub publish: Option<bool>,
pub include: Option<Vec<String>>,
pub exclude: Option<Vec<String>>,
pub metadata: Option<serde_json::Value>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ComponentDef {
pub entrypoint: PathBuf,
pub hash: Option<String>,
}
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
pub struct CapabilitiesDef {
#[serde(default)]
pub net: Vec<String>,
#[serde(default)]
pub kv: Vec<String>,
#[serde(default)]
pub fs_read: Vec<String>,
#[serde(default)]
pub fs_write: Vec<String>,
#[serde(default)]
pub host_process: Vec<String>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct EnvDef {
#[serde(rename = "type")]
pub env_type: String,
pub request: Option<String>,
pub description: Option<String>,
pub default: Option<serde_json::Value>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ContextFileDef {
pub name: String,
pub file: PathBuf,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct CommandDef {
pub name: String,
pub description: Option<String>,
pub file: Option<PathBuf>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct McpServerDef {
pub id: String,
pub description: Option<String>,
#[serde(rename = "type")]
pub server_type: Option<String>,
pub command: Option<String>,
#[serde(default)]
pub args: Vec<String>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct SkillDef {
pub name: String,
pub description: Option<String>,
pub file: PathBuf,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct UplinkDef {
pub name: String,
pub platform: FrontendType,
pub profile: ConnectorProfile,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct LlmProviderDef {
pub id: String,
pub description: Option<String>,
#[serde(default)]
pub capabilities: Vec<String>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ToolDef {
pub name: String,
pub description: String,
pub input_schema: serde_json::Value,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct InterceptorDef {
pub event: String,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct CronDef {
pub name: String,
pub schedule: String,
pub action: String,
}