pub use crate::runtime::run::flow::RunAction;
pub use crate::runtime::tool_call::gate::{SuspendTicket, ToolCallAction};
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum Phase {
RunStart,
StepStart,
BeforeInference,
AfterInference,
BeforeToolExecute,
AfterToolExecute,
StepEnd,
RunEnd,
}
impl std::fmt::Display for Phase {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Self::RunStart => write!(f, "RunStart"),
Self::StepStart => write!(f, "StepStart"),
Self::BeforeInference => write!(f, "BeforeInference"),
Self::AfterInference => write!(f, "AfterInference"),
Self::BeforeToolExecute => write!(f, "BeforeToolExecute"),
Self::AfterToolExecute => write!(f, "AfterToolExecute"),
Self::StepEnd => write!(f, "StepEnd"),
Self::RunEnd => write!(f, "RunEnd"),
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct PhasePolicy {
pub allow_tool_filter_mutation: bool,
pub allow_run_action_mutation: bool,
pub allow_tool_gate_mutation: bool,
}
impl PhasePolicy {
pub const fn read_only() -> Self {
Self {
allow_tool_filter_mutation: false,
allow_run_action_mutation: false,
allow_tool_gate_mutation: false,
}
}
}
impl Phase {
pub const fn policy(self) -> PhasePolicy {
match self {
Self::BeforeInference => PhasePolicy {
allow_tool_filter_mutation: true,
allow_run_action_mutation: true,
allow_tool_gate_mutation: false,
},
Self::AfterInference => PhasePolicy {
allow_tool_filter_mutation: false,
allow_run_action_mutation: true,
allow_tool_gate_mutation: false,
},
Self::BeforeToolExecute => PhasePolicy {
allow_tool_filter_mutation: false,
allow_run_action_mutation: false,
allow_tool_gate_mutation: true,
},
Self::RunStart
| Self::StepStart
| Self::AfterToolExecute
| Self::StepEnd
| Self::RunEnd => PhasePolicy::read_only(),
}
}
}
#[derive(Debug, Clone, PartialEq)]
pub enum StepOutcome {
Continue,
Complete,
Pending(Box<SuspendTicket>),
}