everruns_runtime/lib.rs
1//! # Warning: 0.17.x compatibility only
2//!
3//! `everruns-runtime` is a transitional compatibility API for existing Everruns
4//! 0.17.x applications. It will be removed in Everruns 0.18. It remains usable
5//! and source-compatible throughout 0.17.x; no execution implementation lives
6//! here.
7//!
8//! New ordinary applications use the [`everruns`](https://docs.rs/everruns)
9//! Framework crate, beginning with `use everruns::{Agent, Model};`. Advanced
10//! system integrators use `everruns` plus [`everruns-host`](https://docs.rs/everruns-host)
11//! and focused sibling crates, beginning with
12//! `use everruns_host::{HostBackends, InProcessRuntimeBuilder};`.
13//!
14//! See the authoritative [runtime migration guide](https://docs.everruns.com/framework/runtime-compatibility/)
15//! for exact old-to-new mappings. All crates are part of the
16//! [Everruns](https://everruns.com) ecosystem.
17//!
18//! # 0.17 compatibility example
19//!
20//! ```
21//! use everruns_runtime::{InProcessRuntimeBuilder, RuntimeBackends};
22//!
23//! let builder = InProcessRuntimeBuilder::new().backends(RuntimeBackends::in_memory());
24//! # let _ = builder;
25//! ```
26
27use std::sync::Arc;
28
29use async_trait::async_trait;
30use everruns_core::error::Result;
31use everruns_core::events::Event;
32use everruns_core::message::Message;
33use everruns_core::message_retriever::{InputMessage, MessageRetriever};
34use everruns_core::traits::EventEmitter;
35use everruns_core::typed_id::SessionId;
36
37/// 0.17 name for the canonical host backend bundle.
38pub use everruns_host::HostBackends as RuntimeBackends;
39pub use everruns_host::*;
40
41/// Legacy writable message-store contract retained only for 0.17 source paths.
42///
43/// It is not accepted by [`RuntimeBackends`] and is never used by execution.
44/// Canonical events are the only maintained write path; this shim is scheduled
45/// for deletion in 0.18.
46#[deprecated(
47 since = "0.17.25",
48 note = "execution is event-authoritative; use everruns_host::EventLog and EventHistory"
49)]
50#[async_trait]
51pub trait RuntimeMessageStore: MessageRetriever + Send + Sync {
52 /// Legacy, non-authoritative input-message write.
53 async fn add_input_message(
54 &self,
55 session_id: SessionId,
56 input: InputMessage,
57 ) -> Result<Message>;
58
59 /// Legacy, non-authoritative message write.
60 async fn store_message(&self, session_id: SessionId, message: Message) -> Result<()>;
61}
62
63#[allow(deprecated)]
64#[async_trait]
65impl RuntimeMessageStore for everruns_core::in_memory::InMemoryMessageRetriever {
66 async fn add_input_message(
67 &self,
68 session_id: SessionId,
69 input: InputMessage,
70 ) -> Result<Message> {
71 self.add(session_id, input).await
72 }
73
74 async fn store_message(&self, session_id: SessionId, message: Message) -> Result<()> {
75 self.store(session_id, message).await
76 }
77}
78
79/// Legacy observation trait retained only so 0.17 implementations still name
80/// the path. It is outside maintained execution; use [`EventSink`] for live
81/// post-commit observation and [`EventReader`] for replay.
82#[deprecated(
83 since = "0.17.25",
84 note = "use everruns_host::EventSink and EventReader"
85)]
86#[async_trait]
87pub trait EventBus: EventEmitter {
88 /// Legacy collected-event view.
89 async fn collected_events(&self) -> Vec<Event> {
90 Vec::new()
91 }
92}
93
94#[allow(deprecated)]
95#[async_trait]
96impl<T: EventBus + ?Sized> EventBus for Arc<T> {
97 async fn collected_events(&self) -> Vec<Event> {
98 (**self).collected_events().await
99 }
100}
101
102#[allow(deprecated)]
103#[async_trait]
104impl EventBus for everruns_core::in_memory::InMemoryEventEmitter {
105 async fn collected_events(&self) -> Vec<Event> {
106 self.events().await
107 }
108}