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
impl AgentSessionRuntime
Sourcepub fn new(
session: Arc<AgentSession>,
services: AgentSessionRuntimeServices,
factory: Arc<dyn CreateAgentSessionRuntimeFactory>,
diagnostics: Vec<AgentSessionRuntimeDiagnostic>,
model_fallback_message: Option<String>,
) -> Self
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.
Sourcepub fn session(&self) -> Arc<AgentSession> ⓘ
pub fn session(&self) -> Arc<AgentSession> ⓘ
Snapshot of the current session (cheap Arc clone).
Sourcepub fn diagnostics(&self) -> Vec<AgentSessionRuntimeDiagnostic>
pub fn diagnostics(&self) -> Vec<AgentSessionRuntimeDiagnostic>
Snapshot of diagnostics.
Sourcepub fn model_fallback_message(&self) -> Option<String>
pub fn model_fallback_message(&self) -> Option<String>
Snapshot of the model-fallback warning.
Sourcepub fn set_rebind_session(&self, callback: Option<RebindSessionCallback>)
pub fn set_rebind_session(&self, callback: Option<RebindSessionCallback>)
Set the rebind callback invoked after each replacement.
Sourcepub fn set_before_session_invalidate(
&self,
callback: Option<BeforeSessionInvalidateCallback>,
)
pub fn set_before_session_invalidate( &self, callback: Option<BeforeSessionInvalidateCallback>, )
Set the synchronous pre-invalidate callback invoked during teardown.
Sourcepub async fn switch_session(
&self,
session_path: &str,
options: SwitchSessionOptions,
) -> Result<SwitchOutcome, AgentSessionRuntimeError>
pub async fn switch_session( &self, session_path: &str, options: SwitchSessionOptions, ) -> Result<SwitchOutcome, AgentSessionRuntimeError>
Sourcepub async fn new_session(
&self,
options: NewSessionOptions,
) -> Result<SwitchOutcome, AgentSessionRuntimeError>
pub async fn new_session( &self, options: NewSessionOptions, ) -> Result<SwitchOutcome, AgentSessionRuntimeError>
Sourcepub async fn fork(
&self,
entry_id: &str,
position: ForkPosition,
) -> Result<ForkOutcome, AgentSessionRuntimeError>
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
Sourcepub async fn import_from_jsonl(
&self,
input_path: &str,
cwd_override: Option<&str>,
) -> Result<SwitchOutcome, AgentSessionRuntimeError>
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.
Auto Trait Implementations§
impl !Freeze for AgentSessionRuntime
impl !RefUnwindSafe for AgentSessionRuntime
impl !UnwindSafe for AgentSessionRuntime
impl Send for AgentSessionRuntime
impl Sync for AgentSessionRuntime
impl Unpin for AgentSessionRuntime
impl UnsafeUnpin for AgentSessionRuntime
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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