use std::fmt::{Display, Formatter};
use serde::{Deserialize, Serialize};
use serde_json::Value;
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct AutomatonObjective {
pub objective_id: String,
pub goal: String,
#[serde(default)]
pub input: Value,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct AutomatonContext {
pub owner: String,
pub project: String,
pub run_id: String,
pub step_budget: u32,
#[serde(default)]
pub metadata: Value,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct AutomatonPlan {
pub objective_id: String,
pub steps: Vec<String>,
#[serde(default)]
pub metadata: Value,
}
#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq)]
#[serde(rename_all = "snake_case")]
pub enum AutomatonResult {
Succeeded,
Failed,
Cancelled,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct AutomatonExecutionOutput {
pub result: AutomatonResult,
#[serde(default)]
pub output: Value,
#[serde(default)]
pub trace: Vec<String>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct AutomatonError {
pub code: &'static str,
pub message: String,
}
impl AutomatonError {
pub fn new(code: &'static str, message: impl Into<String>) -> Self {
Self {
code,
message: message.into(),
}
}
}
impl Display for AutomatonError {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
write!(f, "{}: {}", self.code, self.message)
}
}
impl std::error::Error for AutomatonError {}