Skip to main content

AgentSession

Struct AgentSession 

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

The product-level session. Cheap to clone — the harness is behind an Arc.

Implementations§

Source§

impl AgentSession

Source

pub fn new( harness: AgentHarness, catalog: Vec<Model>, scoped_models: Vec<ScopedModel>, cwd: impl Into<PathBuf>, ) -> Self

Wrap an existing harness. catalog is the resolved model catalog the session may switch within; scoped_models is the (possibly empty) settings-driven subset used by Ctrl+P / /model.

Source

pub fn harness(&self) -> &AgentHarness

The wrapped harness, for the call sites (TUI drain task, extension bridge) that already speak the harness API.

Source

pub fn harness_arc(&self) -> Arc<AgentHarness> ⓘ

The Arc handle, for spawning work onto the runtime.

Source

pub fn lane(&self) -> Arc<dyn AgentLane> ⓘ

The main-lane runner.

Source

pub fn cwd(&self) -> &Path

The working directory the session was opened in.

Source

pub fn catalog(&self) -> &[Model]

The resolved model catalog.

Source

pub fn scoped_models(&self) -> &[ScopedModel]

The active scoped-model set ([] → the full catalog is in play).

Source

pub async fn prompt( &self, text: &str, images: Vec<ImageContent>, ) -> HarnessResult<RunResult>

Send a prompt with optional image attachments. Mirrors TS AgentSession.prompt.

Source

pub async fn send_message( &self, message: AgentMessage, ) -> HarnessResult<RunResult>

Send an already-built user message. Mirrors TS AgentSession.sendUserMessage.

Source

pub async fn steer(&self, message: AgentMessage) -> HarnessResult<()>

Queue a steering message for the in-flight run. Mirrors TS AgentSession.steer.

Source

pub async fn follow_up(&self, message: AgentMessage) -> HarnessResult<()>

Queue a follow-up message for after the in-flight run. Mirrors TS AgentSession.followUp.

Source

pub async fn abort(&self) -> HarnessResult<()>

Abort the in-flight run. Mirrors TS AgentSession.abort.

Source

pub async fn model(&self) -> HarnessResult<Model>

The current model.

Source

pub async fn set_model(&self, model: Model) -> HarnessResult<()>

Switch the model. Mirrors TS AgentSession.setModel.

Source

pub async fn thinking_level(&self) -> HarnessResult<ThinkingLevel>

The current thinking level.

Source

pub async fn set_thinking_level( &self, level: ThinkingLevel, ) -> HarnessResult<()>

Set the thinking level. Mirrors TS AgentSession.setThinkingLevel.

Source

pub fn cycle_catalog(&self) -> Vec<Model>

The effective model cycle order: the scoped set when configured, else the full catalog. Mirrors TS AgentSession.getScopedModels.

Source

pub async fn compact(&self, instructions: Option<&str>) -> HarnessResult<()>

Explicit compaction. Mirrors TS AgentSession.compact.

Source

pub async fn retry(&self) -> HarnessResult<Option<RunResult>>

Retry the last turn. The harness owns the retry policy; this re-runs the last user message when one exists. Mirrors TS AgentSession.retry.

Source

pub async fn tip_id(&self) -> HarnessResult<Option<String>>

The current leaf entry id.

Source

pub async fn entries(&self) -> HarnessResult<Vec<Entry>>

All entries on the session, oldest first.

Source

pub async fn snapshot(&self) -> HarnessResult<LaneSnapshot>

The lane read model. Mirrors the TS runtime lane snapshot.

Source

pub async fn name(&self) -> HarnessResult<Option<String>>

Name/label facts. Mirrors TS AgentSession.setName / setLabel.

Source

pub async fn set_name(&self, name: Option<&str>) -> HarnessResult<()>

Set (or clear) the session name.

Source

pub async fn set_label( &self, target_id: &str, label: Option<&str>, ) -> HarnessResult<()>

Attach (or clear) a label on an entry.

Source

pub async fn value(&self, key: &str) -> HarnessResult<Option<Value>>

Read a durable session value (see rpi_harness::session::values).

Source

pub async fn set_value(&self, key: &str, value: Value) -> HarnessResult<()>

Persist a durable session value (latest-wins). Used for per-session display preferences so they survive resume.

Source

pub async fn usage_stats(&self) -> HarnessResult<SessionUsageStats>

Rolled-up usage + context stats for the footer.

Source

pub async fn total_usage(&self) -> HarnessResult<Usage>

The summed usage across every assistant message (for /context).

Source

pub async fn last_assistant_text(&self) -> HarnessResult<Option<String>>

The last finalized assistant text (for /copy). Mirrors TS AgentSession.getLastAssistantText.

Source

pub async fn export_to_html(&self, path: &Path) -> HarnessResult<()>

exportToHtml(). Mirrors TS AgentSession.exportToHtml.

Source

pub async fn export_to_jsonl(&self, path: &Path) -> HarnessResult<()>

exportToJsonl(). Mirrors TS AgentSession.exportToJsonl.

Source

pub async fn export_to_markdown(&self, path: &Path) -> HarnessResult<()>

exportToMarkdown() — the local /export default.

Source

pub async fn export( &self, format: ExportFormat, path: &Path, ) -> HarnessResult<()>

Export to format, deriving the default filename from the session name/leaf when path is a directory.

Source

pub async fn default_export_file_name(&self, format: ExportFormat) -> String

The filename /export would write for format.

Source

pub async fn fork(&self, label: Option<&str>) -> HarnessResult<()>

Fork the session at the current leaf into a labelled branch. The navigation machinery creates the branch; the label tags its tip. Mirrors TS AgentSession.fork.

Source

pub async fn result(&self, run_id: &str) -> HarnessResult<Option<RunResult>>

Read back the terminal outcome of a run by id. Mirrors TS AgentSession.getResult.

Trait Implementations§

Source§

impl Clone for AgentSession

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

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<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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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