use super::execution_context::RuntimeContext;
use crate::kernel::{ExecutionId, StepId};
use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct InvocationServices {
pub memory: bool,
pub artifacts: bool,
pub tools: bool,
}
impl InvocationServices {
pub fn all() -> Self {
Self {
memory: true,
artifacts: true,
tools: true,
}
}
pub fn none() -> Self {
Self::default()
}
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct InvocationContext {
pub runtime: RuntimeContext,
pub input: serde_json::Value,
pub services: InvocationServices,
}
impl InvocationContext {
pub fn new(runtime: RuntimeContext, input: serde_json::Value) -> Self {
Self {
runtime,
input,
services: InvocationServices::default(),
}
}
pub fn with_all_services(mut self) -> Self {
self.services = InvocationServices::all();
self
}
pub fn with_services(mut self, services: InvocationServices) -> Self {
self.services = services;
self
}
pub fn execution_id(&self) -> &ExecutionId {
&self.runtime.execution_id
}
pub fn step_id(&self) -> Option<&StepId> {
self.runtime.step_id.as_ref()
}
pub fn runtime(&self) -> &RuntimeContext {
&self.runtime
}
pub fn input(&self) -> &serde_json::Value {
&self.input
}
pub fn input_str(&self) -> Option<&str> {
self.input.as_str()
}
}