Skip to main content

LashRuntime

Struct LashRuntime 

Source
pub struct LashRuntime { /* private fields */ }
Expand description

Generic runtime for CLI or programmatic embedding.

Implementations§

Source§

impl LashRuntime

Source§

impl LashRuntime

Source

pub fn set_model(&mut self, model: String)

Update model on the runtime config.

Source

pub fn set_model_variant(&mut self, model_variant: Option<String>)

Update model variant on the runtime config.

Source

pub fn set_max_context_tokens(&mut self, max_context_tokens: usize)

Update explicit model context metadata on the runtime config.

Source

pub fn set_provider(&mut self, provider: ProviderHandle)

Update provider on the runtime config.

Source

pub fn set_session_id(&mut self, session_id: Option<String>)

Update session ID metadata on the runtime config.

Source

pub async fn update_session_config( &mut self, provider: Option<ProviderHandle>, model: Option<String>, model_variant: Option<Option<String>>, max_context_tokens: Option<usize>, prompt: Option<PromptLayer>, )

Source

pub async fn set_prompt_template(&mut self, template: PromptTemplate)

Source

pub async fn clear_prompt_template(&mut self)

Source

pub async fn add_prompt_contribution( &mut self, contribution: PromptContribution, )

Source

pub async fn replace_prompt_slot( &mut self, slot: PromptSlot, contributions: impl IntoIterator<Item = PromptContribution>, )

Source

pub async fn clear_prompt_slot(&mut self, slot: PromptSlot)

Source

pub async fn refresh_session_tool_surface(&mut self) -> Result<(), SessionError>

Re-register the current tool surface in the live RLM session.

Source

pub async fn apply_tool_state( &mut self, snapshot: ToolState, ) -> Result<u64, SessionError>

Source§

impl LashRuntime

Source

pub async fn from_embedded_state( policy: SessionPolicy, host: EmbeddedRuntimeHost, services: RuntimeServices, state: PersistedSessionState, ) -> Result<Self, SessionError>

Build a runtime for an embedded host with no background worker support.

Source

pub async fn from_background_state( policy: SessionPolicy, host: BackgroundRuntimeHost, services: RuntimeServices, state: PersistedSessionState, ) -> Result<Self, SessionError>

Build a runtime for a host that supports background plugin work.

Source

pub async fn from_persistent_embedded_state( policy: SessionPolicy, host: EmbeddedRuntimeHost, services: PersistentRuntimeServices, state: PersistedSessionState, ) -> Result<Self, SessionError>

Build a runtime for an embedded host with persistent store support.

Source

pub async fn from_persistent_background_state( policy: SessionPolicy, host: BackgroundRuntimeHost, services: PersistentRuntimeServices, state: PersistedSessionState, ) -> Result<Self, SessionError>

Build a runtime for a background-capable host with persistent store support.

Source

pub async fn from_environment( env: &RuntimeEnvironment, policy: SessionPolicy, state: PersistedSessionState, store: Option<Arc<dyn RuntimePersistence>>, ) -> Result<Self, SessionError>

Embedder-preferred constructor: build a LashRuntime from a shared RuntimeEnvironment.

Everything expensive (plugin factories, HTTP client pool, prompt template, path resolver) lives on the environment and is reused across every runtime the embedder builds. This call is O(plugin-session-registration + state-hydration), not O(full-infrastructure-init).

  • env — the shared environment. env.plugin_host must be set.
  • policy — per-session policy (model, provider, execution mode).
  • state — persisted session state (empty for a fresh session).
  • store — per-session store. None builds an embedded runtime with no persistence; Some builds a persistent background-capable runtime.
Source

pub async fn park(self) -> Result<ParkedSession, SessionError>

Persist any dirty state and drop the runtime, returning a lightweight handle the embedder can cache and resume later via LashRuntime::resume. This is the webserver-embedder handoff primitive: the handle holds only the session id, policy, and store reference — no graph nodes, no plugin session, no HTTP client.

Source

pub async fn resume( parked: ParkedSession, env: &RuntimeEnvironment, ) -> Result<Self, SessionError>

Resume a previously parked session against a shared environment. Loads only the active-path graph when env.residency == ActivePathOnly; under KeepAll loads the full graph (current behavior).

Source

pub async fn get_historic_node( &self, node_id: &str, ) -> Result<Option<SessionNodeRecord>, SessionError>

Opt-in async read for historic (non-active-path) nodes under Residency::ActivePathOnly. Plugins that walk the full graph call this instead of session_graph().find_node() so missing nodes surface as Ok(None) rather than silently missing.

Source

pub async fn orphaned_node_ids(&self) -> Result<Vec<String>, SessionError>

Store-resident node IDs that are NOT reachable from the current leaf — i.e. orphans eligible for tombstoning. lash owns RAM; the host owns disk lifecycle, so this is a primitive the host calls on its own schedule (e.g. every N turns, or off-peak).

Typical autonomous-agent loop:

let orphans = runtime.orphaned_node_ids().await?;
if !orphans.is_empty() {
    store.tombstone_nodes(&orphans).await;
}
// And less often:
store.vacuum().await;
Source§

impl LashRuntime

Source

pub fn session_id(&self) -> &str

Source

pub fn tool_state(&self) -> Result<ToolState, SessionError>

Source

pub fn set_mode_turn_options(&mut self, options: ModeTurnOptions)

Override mode-owned turn options for this session.

Source

pub fn export_state(&self) -> SessionStateEnvelope

Export current session state for inspection/UI purposes. This keeps persistence-heavy snapshots untouched; callers that need a fully persisted view should use export_persisted_state.

Source

pub fn read_view(&self) -> SessionReadView

Source

pub fn export_persistence_state(&self) -> PersistedSessionState

Export the narrow persistence snapshot used by stores and resume logic.

Source

pub fn apply_persistence_state(&mut self, state: PersistedSessionState)

Source

pub fn export_persisted_state(&self) -> PersistedSessionState

Export a persistence-ready state envelope with dynamic/plugin snapshots refreshed from the live session.

Source

pub fn usage_report(&self) -> SessionUsageReport

Source

pub async fn await_background_work(&mut self) -> Result<(), SessionError>

Source

pub fn session_manager( &self, ) -> Result<Arc<dyn RuntimeSessionHost>, PluginActionInvokeError>

Source

pub fn plugin_session(&self) -> Option<Arc<PluginSession>>

The plugin session bound to the currently active runtime session, if any.

Source

pub fn turn_input_injection_bridge( &self, ) -> Result<TurnInputInjectionBridge, SessionError>

Source

pub async fn rewrite_history( &mut self, trigger: RewriteTrigger, ) -> Result<bool, PluginActionInvokeError>

Run the registered history rewrite pipeline against the current state, applying the resulting messages back onto the runtime. Returns true when at least one rewriter produced a summary or otherwise mutated the message list.

Source§

impl LashRuntime

Source

pub fn set_persisted_state(&mut self, state: PersistedSessionState)

Replace the host-owned state envelope.

Source

pub async fn append_session_nodes( &mut self, request: AppendSessionNodesRequest, ) -> Result<AppendSessionNodesResult, SessionError>

Source

pub async fn apply_mode_session_extension( &mut self, extension: ModeSessionExtensionHandle, ) -> Result<(), SessionError>

Source

pub async fn validate_mode_turn_extension( &mut self, extension: &ModeTurnExtensionHandle, ) -> Result<(), SessionError>

Source

pub async fn branch_to_node( &mut self, node_id: Option<String>, ) -> Result<SessionStateEnvelope, SessionError>

Source

pub async fn activate_managed_session( &mut self, session_id: &str, ) -> Result<(), SessionError>

Promote a managed child session into the foreground runtime.

Child sessions created through RuntimeSessionHost::create_session are real runtimes, not serialized placeholders. Foreground handoff must therefore claim that runtime instead of reconstructing a new empty state in the UI.

Source

pub async fn reset_session(&mut self) -> Result<(), SessionError>

Reset the RLM session on the underlying session runtime.

Source

pub async fn snapshot_execution_state( &mut self, ) -> Result<Option<Vec<u8>>, SessionError>

Explicitly snapshot execution-mode-local state, if any.

Source

pub async fn restore_execution_state( &mut self, snapshot: &[u8], ) -> Result<(), SessionError>

Explicitly restore execution-mode-local state from an opaque snapshot blob.

Source

pub async fn invoke_plugin_action( &self, name: &str, args: Value, session_id: Option<String>, ) -> Result<ToolResult, PluginActionInvokeError>

Source§

impl LashRuntime

Source

pub async fn stream_turn( &mut self, input: TurnInput, events: &dyn EventSink, cancel: CancellationToken, ) -> Result<AssembledTurn, RuntimeError>

Run a single turn and stream events to the host sink.

Source

pub async fn stream_turn_following_handoffs( &mut self, input: TurnInput, events: &dyn EventSink, cancel: CancellationToken, ) -> Result<FollowedTurn, RuntimeError>

Stream one logical host turn, following foreground handoffs until a non-handoff outcome is reached.

RLM continue_as creates a successor session with queued first-turn input. Hosts that only care about the benchmark/app answer should not need to special-case that intermediate outcome; this helper activates each successor and drives its queued first turn with the normal runtime turn guards.

Source

pub async fn stream_turn_events_following_handoffs( &mut self, input: TurnInput, turn_events: &dyn TurnActivitySink, cancel: CancellationToken, ) -> Result<FollowedTurn, RuntimeError>

Source

pub async fn stream_turn_with_events_following_handoffs( &mut self, input: TurnInput, events: &dyn EventSink, turn_events: &dyn TurnActivitySink, cancel: CancellationToken, ) -> Result<FollowedTurn, RuntimeError>

Source

pub async fn run_turn_assembled( &mut self, input: TurnInput, cancel: CancellationToken, ) -> Result<AssembledTurn, RuntimeError>

Run a single turn and return only the assembled terminal result.

Source

pub async fn stream_prepared_turn( &mut self, messages: MessageSequence, _previous_prompt_usage: Option<PromptUsage>, mode_turn_options: Option<ModeTurnOptions>, mode_extension: Option<ModeTurnExtensionHandle>, turn_context: TurnContext, trace_turn_id: String, turn_index: usize, events: &dyn EventSink, turn_events: &dyn TurnActivitySink, cancel: CancellationToken, ) -> Result<AssembledTurn, RuntimeError>

Run a turn using host-prepared message history.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more