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, CompactionCheckpoint, CompactionCheckpointPayload,
44    CompactionCheckpointStore, EgressService, McpToolInvoker, MessageQuery,
45    ProactiveCompactionAttempt, RuntimeAgent, UtilityLlmService, annotation_hook, capabilities,
46    compaction_policy, connection_services, delegation_services, durability, event_emitter, events,
47    execution_loading, file_services, finalized_tool_calls, image_services, llm_conversions,
48    llm_error_hook, localization, message, message_retriever, mount_fs, network_access,
49    output_guardrail, runtime_context, session_files, session_services, session_task,
50    subagent_delegation, tool_context, tool_execution, tool_fingerprint, tool_narration, tools,
51};
52pub(crate) use everruns_provider::user_facing_error::{
53    ErrorDisclosure, UserFacingError, UserFacingErrorContext, codes as user_facing_error_codes,
54};
55pub(crate) use everruns_provider::{
56    ChatDriver, CompactInputItem, ProviderEndpoint, ProviderOpaqueContext, compact,
57    driver_registry, error, llm_retry, model, model_profiles, tool_types, typed_id,
58};
59
60pub(crate) mod tool_call_integrity {
61    pub(crate) use everruns_core::{
62        retain_complete_llm_tool_exchanges_for_request, retain_complete_message_tool_exchanges,
63    };
64}
65
66pub use execution::{
67    ActAtom, ActInput, ActResult, ClientSideToolHook, ConnectionSetupHook, ExecutionContext,
68    InputAtom, InputAtomInput, InputAtomResult, NativeExecutionCounts, OutputHardLimitHook,
69    PostActAction, PostActHook, ReasonAtom, ReasonInput, ReasonResult, ToolCallResult,
70};
71pub use machine::{Execution, ExecutionTransition, TurnExecution};
72pub use phase_effects::{PhaseEffect, PhaseEffectSink};
73pub use turn::{
74    ActOutcome, ActPlan, ActSchedulingFacts, ActivityOutcome, HostFacts, TurnLifecycleEffect,
75    TurnPlan, TurnState, plan_after_act, plan_after_process_input, plan_after_reason,
76    plan_next_turn, reason_schedules_act,
77};