enact-core 0.0.2

Core agent runtime for Enact - Graph-Native AI agents
Documentation
//! Streaming - Event delivery and persistence
//!
//! This module handles **delivery** of events to consumers. It subscribes to
//! kernel events and delivers them via SSE, persistence, etc.
//!
//! ## Important: Source of Truth
//!
//! IDs and Events are DEFINED in `kernel/` (source of truth).
//! This module RE-EXPORTS them for convenience and provides:
//! - **event_logger.rs**: Append-only event log (EventStore, EventLog)
//! - **event_stream.rs**: Wire format for SSE (StreamEvent, data-* protocol)
//!
//! ## Architecture
//!
//! ```text
//! ExecutionKernel (owns IDs and Events)
//!//!       │ emit events
//!//! ┌─────────────────────────────────────────────────────────┐
//! │                    streaming/                            │
//! │  ┌────────────┐  ┌────────────────────┐                 │
//! │  │event_logger│  │  event_stream.rs   │                 │
//! │  │ (persist)  │  │  (wire format)     │                 │
//! │  └────────────┘  └─────────┬──────────┘                 │
//! └────────────────────────────┼────────────────────────────┘
//!//!                ┌─────────────┼─────────────────┐
//!                ▼             ▼                 ▼
//!          ┌──────────┐ ┌───────────┐      ┌───────────┐
//!          │   TUI    │ │ GUI (SSE) │      │ telemetry │
//!          │(ratatui) │ │ (web)     │      │  (OTel)   │
//!          └──────────┘ └───────────┘      └───────────┘
//! ```
//!
//! ## Event Protocol
//! All events use `data-*` prefix for SSE compatibility:
//! - Standard: `data-text-start`, `data-text-delta`, `data-finish`, etc.
//! - Custom: `data-execution-start`, `data-step-start`, etc.
//!
//! @see docs/TECHNICAL/01-EXECUTION-TELEMETRY.md
//! @see https://ai-sdk.dev/docs/ai-sdk-ui/stream-protocol

mod event_logger;
mod event_stream;
mod jsonl_event_store;
mod jsonl_state_store;
mod pause_cancel;
mod sse;

// =============================================================================
// Stream Events (wire format for SSE)
// =============================================================================
pub use event_stream::{EventEmitter, EventStream, StreamEvent, StreamMode};

// =============================================================================
// Event Log (persistence)
// =============================================================================
pub use event_logger::{EventLog, EventLogEntry, EventStore, InMemoryEventStore};
pub use jsonl_event_store::JsonlEventStore;
pub use jsonl_state_store::JsonlStateStore;

// =============================================================================
// Re-exports from kernel (source of truth)
// =============================================================================
// IDs and Events are DEFINED in kernel/. We re-export for convenience.
pub use crate::kernel::{
    prefixes,
    // IDs
    ArtifactId,
    // Events
    ControlAction,
    ControlActor,
    ControlEvent,
    ControlOutcome,
    DecisionAlternative,
    DecisionInput,
    DecisionRecord,
    DecisionType,
    Event,
    ExecutionContext,
    ExecutionEvent,
    ExecutionEventType,
    ExecutionId,
    GraphId,
    MessageId,
    ModelContext,
    NodeId,
    ParentLink,
    ParentType,
    RunId,
    StepId,
    StepType,
    TenantId,
    ThreadId,
    UserId,
};

// =============================================================================
// Protection Layer (feat-09: Guardrails)
// =============================================================================
// Output processors that run BEFORE storage/streaming.
// @see docs/TECHNICAL/17-GUARDRAILS-PROTECTION.md
// @see docs/TECHNICAL/25-STREAM-PROCESSORS.md
mod protected_emitter;
pub mod protection;

pub use protected_emitter::ProtectedEventEmitter;
pub use protection::{
    DataDestination, EncryptionProcessor, OutputProcessor, PiiProtectionProcessor, ProcessedEvent,
    ProcessorPipeline, ProtectionContext,
};