use uuid::Uuid;
use ironflow_store::models::StepKind;
use crate::config::{AgentStep, StepConfig};
use crate::context::WorkflowContext;
use crate::error::EngineError;
#[derive(Debug, Clone, PartialEq)]
pub struct AgentReply<A> {
pub answer: A,
pub environment_id: Option<String>,
pub account_id: Option<Uuid>,
}
impl WorkflowContext {
pub async fn agent<C: AgentStep>(
&mut self,
name: &str,
config: C,
) -> Result<C::Answer, EngineError> {
self.agent_with_meta(name, config)
.await
.map(|reply| reply.answer)
}
pub async fn agent_with_meta<C: AgentStep>(
&mut self,
name: &str,
config: C,
) -> Result<AgentReply<C::Answer>, EngineError> {
let output = self
.execute_step(
name,
StepKind::Agent,
StepConfig::Agent(config.into_config()),
)
.await?;
let environment_id = output.environment_id.clone();
let account_id = output.account_id;
Ok(AgentReply {
answer: C::answer(output)?,
environment_id,
account_id,
})
}
}