pe-core 0.1.0

Core types for Potential Expectations — messages, channels, state, traits
Documentation
//! Declarative macros for pe-core.
//!
//! `core_state_fields!()` — convenience macro that embeds the standard
//! `CoreState` fields into a user's state struct.

/// Embeds the standard CoreState fields into a state struct.
///
/// These fields are required for any state that implements `CoreState`.
/// The `#[core]` attribute signals to `#[derive(State)]` that it should
/// generate the `CoreState` trait impl.
///
/// # Usage
///
/// ```ignore
/// use pe_core::core_state_fields;
///
/// #[derive(State, Clone, Debug, Serialize, Deserialize)]
/// struct MyAgentState {
///     core_state_fields!(),
///
///     // Your custom fields here
///     topic: String,
/// }
/// ```
///
/// # Expands to
///
/// ```ignore
/// #[core]
/// messages: Vec<Message>,
/// #[core]
/// iterations: u32,
/// #[core]
/// thread_id: String,
/// #[core]
/// context: ExecutionContext,
/// ```
#[macro_export]
macro_rules! core_state_fields {
    () => {
        /// Message history — uses add_messages reducer (append + dedup by id)
        #[core]
        pub messages: Vec<$crate::message::Message>,

        /// Current iteration count — LastValue channel
        #[core]
        pub iterations: u32,

        /// Thread identifier — LastValue channel
        #[core]
        pub thread_id: String,

        /// Execution context injected by runtime — LastValue channel
        #[core]
        pub context: $crate::state::ExecutionContext,
    };
}