runifold_core/effect.rs
1use serde::{Deserialize, Serialize};
2use serde_json::Value;
3
4use crate::{CapabilityId, EffectClass, EffectId, InvocationId};
5
6/// The operation requested by an external effect.
7#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
8#[non_exhaustive]
9pub enum EffectKind {
10 /// Invoke a model.
11 Model,
12 /// Invoke a tool.
13 Tool,
14 /// Invoke another agent.
15 Agent,
16 /// Ask an external authority for approval.
17 Approval,
18 /// Wait for a timer or external wakeup.
19 Wait,
20 /// Invoke a namespaced extension.
21 Extension(String),
22}
23
24/// A runtime request to perform external work.
25#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
26pub struct EffectRequest {
27 /// Unique effect identity.
28 pub effect_id: EffectId,
29 /// Stable invocation identity used for correlation and idempotency.
30 pub invocation_id: InvocationId,
31 /// Operation category.
32 pub kind: EffectKind,
33 /// Capability required to perform the effect.
34 pub capability_id: CapabilityId,
35 /// Input after local validation.
36 pub input: Value,
37 /// Side-effect classification at invocation time.
38 pub effect_class: EffectClass,
39 /// Optional stable key for an idempotent external system.
40 pub idempotency_key: Option<String>,
41}