use salvor_runtime::RuntimeError;
use thiserror::Error;
#[derive(Debug, Error)]
pub enum EngineError {
#[error("map node `{node}`: the `over` reference `{over}` did not resolve to a list")]
MapOverNotAList {
node: String,
over: String,
},
#[error("map node `{node}`: {detail}")]
UnsupportedMapBody {
node: String,
detail: String,
},
#[error("branch node `{node}`: no case condition matched the routed value")]
NoBranchCaseMatched {
node: String,
},
#[error(
"branch node `{node}`: the decision agent replied `{reply}`, which is not one of the cases [{}]",
.cases.join(", ")
)]
BranchDecisionUnmatched {
node: String,
reply: String,
cases: Vec<String>,
},
#[error("node `{node}`: the engine does not execute `{kind}` nodes yet")]
UnsupportedNode {
node: String,
kind: &'static str,
},
#[error("agent node `{node}`: no agent registered for hash `{agent_hash}`")]
UnknownAgent {
node: String,
agent_hash: String,
},
#[error("tool node `{node}`: no tool registered under the name `{tool}`")]
UnknownTool {
node: String,
tool: String,
},
#[error("the graph is not a well-formed acyclic document: {detail}")]
MalformedGraph {
detail: String,
},
#[error("tool node `{node}` failed: {message}")]
ToolFailed {
node: String,
message: String,
},
#[error("could not serialize the graph document to hash it: {0}")]
GraphEncode(#[source] serde_json::Error),
#[error(transparent)]
Runtime(#[from] RuntimeError),
}