use monoloop_contracts::ToolExecutionId;
use tokio::sync::oneshot;
#[derive(Clone, Debug)]
pub struct StartToolExecution {
pub execution_id: ToolExecutionId,
pub tool_action_id: String,
pub tool_name: String,
pub request_payload: String,
pub request_generation: u64,
}
#[derive(Clone, Debug, thiserror::Error)]
#[error("tool runtime: {0}")]
pub struct ToolRuntimeError(pub String);
#[derive(Clone, Debug)]
pub struct ToolRuntimeTerminal {
pub outcome: monoloop_contracts::OutboundToolOutcome,
pub payload: String,
}
#[derive(Debug)]
pub struct ToolExecutionHandle {
pub execution_id: ToolExecutionId,
pub completion: Option<oneshot::Receiver<ToolRuntimeTerminal>>,
}
pub trait ToolRuntime: Send + Sync {
fn start(&self, request: StartToolExecution) -> Result<ToolExecutionHandle, ToolRuntimeError>;
}
#[derive(Clone, Debug, Default)]
pub struct NoToolRuntime;
impl NoToolRuntime {
pub fn new() -> Self {
Self
}
}
impl ToolRuntime for NoToolRuntime {
fn start(&self, _request: StartToolExecution) -> Result<ToolExecutionHandle, ToolRuntimeError> {
Err(ToolRuntimeError(
"NoToolRuntime.start must never be called with EmptyToolRegistry".into(),
))
}
}