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;
31mod machine;
32mod phase_effects;
33#[cfg(test)]
34mod test_fixtures;
35mod turn;
36
37// Internal aliases keep the execution algorithms focused on their contracts
38// while preserving the one-way engine -> core/provider/capability boundary.
39pub(crate) use everruns_capability::CapabilityRef;
40pub(crate) use everruns_core::{
41    COMPACTION_CHECKPOINT_FORMAT_VERSION, CompactionCheckpoint, CompactionCheckpointPayload,
42    CompactionCheckpointStore, EgressService, McpToolInvoker, MessageQuery,
43    ProactiveCompactionAttempt, RuntimeAgent, UtilityLlmService, annotation_hook, capabilities,
44    compaction_policy, connection_services, delegation_services, durability, event_emitter, events,
45    execution_loading, finalized_tool_calls, image_services, llm_conversions, llm_error_hook,
46    localization, message, message_retriever, mount_fs, network_access, output_guardrail,
47    runtime_context, session_files, session_services, session_task, subagent_delegation,
48    tool_context, tool_execution, tool_fingerprint, tool_narration, tools,
49};
50pub(crate) use everruns_provider::user_facing_error::{
51    ErrorDisclosure, UserFacingError, UserFacingErrorContext, codes as user_facing_error_codes,
52};
53pub(crate) use everruns_provider::{
54    ChatDriver, CompactInputItem, ProviderEndpoint, ProviderOpaqueContext, compact,
55    driver_registry, error, llm_retry, model, model_profiles, tool_types, typed_id,
56};
57
58pub(crate) mod tool_call_integrity {
59    pub(crate) use everruns_core::{
60        retain_complete_llm_tool_exchanges_for_request, retain_complete_message_tool_exchanges,
61    };
62}
63
64pub use execution::{
65    ActAtom, ActInput, ActResult, ClientSideToolHook, ConnectionSetupHook, ExecutionContext,
66    InputAtom, InputAtomInput, InputAtomResult, OutputHardLimitHook, PostActAction, PostActHook,
67    ReasonAtom, ReasonInput, ReasonResult, ToolCallResult,
68};
69pub use machine::{Execution, ExecutionTransition, TurnExecution};
70pub use phase_effects::{PhaseEffect, PhaseEffectSink};
71pub use turn::{
72    ActOutcome, ActPlan, ActSchedulingFacts, ActivityOutcome, HostFacts, TurnLifecycleEffect,
73    TurnPlan, TurnState, plan_after_act, plan_after_process_input, plan_after_reason,
74    plan_next_turn, reason_schedules_act,
75};