ras-agent 4.0.0

Agent step loop, history, plan, rerun orchestration
Documentation
use ras_types::ActionName;
use serde::{Deserialize, Deserializer, Serialize};

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct AgentBrain {
    #[serde(default, deserialize_with = "null_to_empty")]
    pub evaluation_previous_goal: String,
    #[serde(default, deserialize_with = "null_to_empty")]
    pub memory: String,
    #[serde(default, deserialize_with = "null_to_empty")]
    pub next_goal: String,
}

fn null_to_empty<'de, D>(de: D) -> Result<String, D::Error>
where
    D: Deserializer<'de>,
{
    use serde_json::Value;
    let v = Value::deserialize(de)?;
    Ok(match v {
        Value::Null => String::new(),
        Value::String(s) => s,
        other => other.to_string(),
    })
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct PlanItem {
    pub step: u32,
    pub description: String,
    pub completed: bool,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct AgentOutput {
    pub current_state: AgentBrain,
    pub action: Vec<ActionInvocation>,
    pub plan: Option<Vec<PlanItem>>,
    pub current_plan_item: Option<u32>,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ActionInvocation {
    pub name: ActionName,
    pub parameters: serde_json::Value,
}