Skip to main content

everruns_engine/
lib.rs

1#![cfg_attr(test, allow(clippy::unwrap_used, clippy::expect_used))]
2//! Shared turn planning and Input/Reason/Act execution for hosts in the
3//! [Everruns](https://everruns.com) ecosystem.
4//!
5//! [`TurnExecution`] owns the serializable state machine shared by every
6//! execution driver. Given a parsed [`ActivityOutcome`] and host-resolved
7//! [`HostFacts`], it returns the next [`TurnPlan`] and ordered
8//! [`TurnLifecycleEffect`]s. Framework applications use `everruns`; this
9//! focused crate lets in-process, durable, and custom hosts share one turn
10//! model.
11//!
12//! Planning is sans I/O: hosts pass resolved facts and perform returned
13//! lifecycle effects. The execution phases are portable async algorithms over
14//! injected core/provider contracts such as [`everruns_core::MessageRetriever`],
15//! [`everruns_core::EventEmitter`], and [`everruns_core::ToolExecutor`]. The
16//! crate does not select stores, transports, processes, or deployment services.
17//! [`Execution`] is the driver boundary. `everruns-host` implements it with
18//! process-local state; `everruns-durable` implements it with checkpointed
19//! state between scheduled activities. Both share phase behavior and turn
20//! transitions without introducing an engine-to-host dependency.
21//!
22//! # Example
23//!
24//! ```
25//! use everruns_engine::{TurnPlan, TurnState};
26//!
27//! fn accepts_plan(_state: &TurnState, _plan: &TurnPlan) {}
28//! # let _ = accepts_plan;
29//! ```
30
31mod execution;
32pub use execution::configured_max_tool_concurrency;
33mod machine;
34pub mod native_async;
35mod phase_effects;
36#[cfg(test)]
37mod test_fixtures;
38mod turn;
39
40// Internal aliases keep the execution algorithms focused on their contracts
41// while preserving the one-way engine -> core/provider/capability boundary.
42pub(crate) use everruns_capability::CapabilityRef;
43pub(crate) use everruns_core::{
44    COMPACTION_CHECKPOINT_FORMAT_VERSION, ClassifierService, CompactionCheckpoint,
45    CompactionCheckpointPayload, CompactionCheckpointStore, EgressService, McpToolInvoker,
46    MessageQuery, ProactiveCompactionAttempt, RuntimeAgent, UtilityLlmService, annotation_hook,
47    capabilities, compaction_policy, connection_services, delegation_services, durability,
48    event_emitter, events, execution_loading, file_services, finalized_tool_calls, image_services,
49    llm_conversions, llm_error_hook, localization, message, message_retriever, mount_fs,
50    network_access, output_guardrail, runtime_context, session_files, session_services,
51    session_task, subagent_delegation, tool_context, tool_execution, tool_fingerprint,
52    tool_narration, tools,
53};
54pub(crate) use everruns_provider::user_facing_error::{
55    ErrorDisclosure, UserFacingError, UserFacingErrorContext, codes as user_facing_error_codes,
56};
57pub(crate) use everruns_provider::{
58    ChatDriver, CompactInputItem, ProviderEndpoint, ProviderOpaqueContext, compact,
59    driver_registry, error, llm_retry, model, model_profiles, tool_types, typed_id,
60};
61
62pub(crate) mod tool_call_integrity {
63    pub(crate) use everruns_core::{
64        retain_complete_llm_tool_exchanges_for_request, retain_complete_message_tool_exchanges,
65    };
66}
67
68pub use execution::{
69    ActAtom, ActInput, ActResult, ClientSideToolHook, ConnectionSetupHook, ExecutionContext,
70    InputAtom, InputAtomInput, InputAtomResult, NativeExecutionCounts, OutputHardLimitHook,
71    PostActAction, PostActHook, ReasonAtom, ReasonInput, ReasonResult, ToolCallResult,
72};
73pub use machine::{Execution, ExecutionTransition, TurnExecution};
74pub use phase_effects::{PhaseEffect, PhaseEffectSink};
75pub use turn::{
76    ActOutcome, ActPlan, ActSchedulingFacts, ActivityOutcome, HostFacts, TurnLifecycleEffect,
77    TurnPlan, TurnState, plan_after_act, plan_after_process_input, plan_after_reason,
78    plan_next_turn, reason_schedules_act,
79};