marona 5.5.0

Marona Agents, MCP server and App authoring, B2A, D2A, realtime and A2A
Documentation
use serde::{Deserialize, Serialize};
use serde_json::{json, Map, Value};

pub const PROTOCOL_VERSION: &str = "2025-11-25";

#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)]
#[serde(rename_all = "snake_case")]
pub enum ExecutionMode {
    Online,
    Offline,
    Hybrid,
}

#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
pub struct ExecutionTarget {
    #[serde(rename = "type")]
    pub target_type: String,
    #[serde(flatten)]
    pub config: Map<String, Value>,
}

#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)]
pub struct PermissionSpec {
    pub key: String,
    pub name: String,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub description: Option<String>,
    #[serde(default = "yes")]
    pub required: bool,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub scope: Option<String>,
}

#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
pub struct AuthConfig {
    #[serde(default)]
    pub is_auth_required: bool,
    #[serde(default = "auth_none")]
    pub auth_type: String,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub auth_instructions: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub connection_schema: Option<Value>,
}

impl Default for AuthConfig {
    fn default() -> Self {
        Self {
            is_auth_required: false,
            auth_type: auth_none(),
            auth_instructions: None,
            connection_schema: None,
        }
    }
}

#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
pub struct HostingConfig {
    pub mode: String,
    pub runtime: String,
    #[serde(default)]
    pub environment: Map<String, Value>,
    #[serde(default)]
    pub secrets: Map<String, Value>,
    #[serde(default)]
    pub runtime_config: Map<String, Value>,
}

impl Default for HostingConfig {
    fn default() -> Self {
        Self {
            mode: "self_hosted".into(),
            runtime: "rust".into(),
            environment: Map::new(),
            secrets: Map::new(),
            runtime_config: Map::new(),
        }
    }
}

#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
pub struct ToolSpec {
    pub name: String,
    pub title: String,
    pub description: String,
    pub input_schema: Value,
    pub output_schema: Value,
    pub is_destructive: bool,
    pub requires_user_confirmation: bool,
    #[serde(default)]
    pub system: bool,
}

pub fn standard_output_schema() -> Value {
    json!({
        "type": "object",
        "properties": {
            "status": {"type": "string"}, "success": {"type": "boolean"},
            "message": {"type": "string"}, "content": {"type": "string"},
            "content_type": {"type": "string"}, "presentation_hint": {"type": "string"},
            "context": {"type": "string"}, "data": {"type": "object", "additionalProperties": true},
            "items": {"type": "array", "items": {}}, "count": {"type": "integer"},
            "artifacts": {"type": "array", "items": {"type": "object", "additionalProperties": true}},
            "job": {"type": "object", "additionalProperties": true}
        },
        "required": ["status", "success", "message", "content", "content_type", "presentation_hint", "context"],
        "additionalProperties": true
    })
}

pub fn standard_attachment_schema() -> Value {
    json!({"type":"object","properties":{
        "artifact_id":{"type":"string"},"filename":{"type":"string"},"mime_type":{"type":"string"},
        "kind":{"type":"string"},"url":{"type":"string"},"file_url":{"type":"string"},
        "content_base64":{"type":"string"},"content":{"type":"string"},
        "metadata":{"type":"object","additionalProperties":true}},"additionalProperties":true})
}

pub fn standard_attachments_property() -> Value {
    json!({"type":"array","description":"User-provided files or runtime artifacts.","items":standard_attachment_schema()})
}

fn yes() -> bool {
    true
}
fn auth_none() -> String {
    "none".into()
}