use crate::id::*;
use serde::{Deserialize, Serialize};
#[non_exhaustive]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(tag = "type", rename_all = "snake_case")]
pub enum Effect {
WriteMemory {
scope: Scope,
key: String,
value: serde_json::Value,
},
DeleteMemory {
scope: Scope,
key: String,
},
Signal {
target: WorkflowId,
payload: SignalPayload,
},
Delegate {
agent: AgentId,
input: Box<OperatorInput>,
},
Handoff {
agent: AgentId,
state: serde_json::Value,
},
Log {
level: LogLevel,
message: String,
data: Option<serde_json::Value>,
},
Custom {
effect_type: String,
data: serde_json::Value,
},
}
use crate::operator::OperatorInput;
#[non_exhaustive]
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Hash)]
#[serde(rename_all = "snake_case")]
pub enum Scope {
Session(SessionId),
Workflow(WorkflowId),
Agent {
workflow: WorkflowId,
agent: AgentId,
},
Global,
Custom(String),
}
#[non_exhaustive]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct SignalPayload {
pub signal_type: String,
pub data: serde_json::Value,
}
impl SignalPayload {
pub fn new(signal_type: impl Into<String>, data: serde_json::Value) -> Self {
Self {
signal_type: signal_type.into(),
data,
}
}
}
#[non_exhaustive]
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
#[serde(rename_all = "snake_case")]
pub enum LogLevel {
Trace,
Debug,
Info,
Warn,
Error,
}