Skip to main content

AgentSessionRuntime

Struct AgentSessionRuntime 

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

Owns the current AgentSession plus cwd-bound services, and drives the replacement pipeline for new / switch / fork / import.

Not Clone. Callers hold it behind Arc<AgentSessionRuntime>; interior mutability covers session + services so replacement operations can run through a shared reference. A serializing async mutex prevents concurrent replacement operations from interleaving teardown / apply / rebind.

Implementations§

Source§

impl AgentSessionRuntime

Source

pub fn new( session: Arc<AgentSession>, services: AgentSessionRuntimeServices, factory: Arc<dyn CreateAgentSessionRuntimeFactory>, diagnostics: Vec<AgentSessionRuntimeDiagnostic>, model_fallback_message: Option<String>, ) -> Self

Construct the runtime from an initial session + services + factory.

Source

pub fn session(&self) -> Arc<AgentSession>

Snapshot of the current session (cheap Arc clone).

Source

pub fn cwd(&self) -> String

Effective cwd.

Source

pub fn agent_dir(&self) -> String

Agent directory (preserved across replacements).

Source

pub fn diagnostics(&self) -> Vec<AgentSessionRuntimeDiagnostic>

Snapshot of diagnostics.

Source

pub fn model_fallback_message(&self) -> Option<String>

Snapshot of the model-fallback warning.

Source

pub fn set_rebind_session(&self, callback: Option<RebindSessionCallback>)

Set the rebind callback invoked after each replacement.

Source

pub fn set_before_session_invalidate( &self, callback: Option<BeforeSessionInvalidateCallback>, )

Set the synchronous pre-invalidate callback invoked during teardown.

Source

pub async fn switch_session( &self, session_path: &str, options: SwitchSessionOptions, ) -> Result<SwitchOutcome, AgentSessionRuntimeError>

Switch to a different session file (resume).

§Errors

See AgentSessionRuntimeError.

Source

pub async fn new_session( &self, options: NewSessionOptions, ) -> Result<SwitchOutcome, AgentSessionRuntimeError>

Start a new session in the current cwd.

§Errors

See AgentSessionRuntimeError.

Source

pub async fn fork( &self, entry_id: &str, position: ForkPosition, ) -> Result<ForkOutcome, AgentSessionRuntimeError>

Fork the session at entry_id.

position = Before (default): the entry must be a user message; the fork point is that message’s parent and selected_text is returned. position = At: the fork point is the entry itself (clone subtree).

For persisted sessions, the forked branch is written to a new file under the session directory. For in-memory sessions, a fresh in-memory manager is constructed (the mutated branch on the old manager is not carried over — until AgentSession accepts a shared Arc<AsyncMutex<SessionManager>>, matching the TS single-reference pattern).

§Errors

See AgentSessionRuntimeError.

Source

pub async fn import_from_jsonl( &self, input_path: &str, cwd_override: Option<&str>, ) -> Result<SwitchOutcome, AgentSessionRuntimeError>

Import a JSONL session file and switch to it.

§Errors

Returns AgentSessionRuntimeError::ImportNotFound when the input path does not exist.

Source

pub async fn dispose(&self)

Dispose the current session and the runtime.

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<Unshared, Shared> IntoShared<Shared> for Unshared
where Shared: FromUnshared<Unshared>,

Source§

fn into_shared(self) -> Shared

Creates a shared type from an unshared type.
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

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

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + 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: Sized + 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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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