Skip to main content

everruns_engine/
lib.rs

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