pub struct AgentSession { /* private fields */ }Expand description
The product-level session. Cheap to clone — the harness is behind an Arc.
Implementations§
Source§impl AgentSession
impl AgentSession
Sourcepub fn new(
harness: AgentHarness,
catalog: Vec<Model>,
scoped_models: Vec<ScopedModel>,
cwd: impl Into<PathBuf>,
) -> Self
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+M / /model.
Sourcepub fn harness(&self) -> &AgentHarness
pub fn harness(&self) -> &AgentHarness
The wrapped harness, for the call sites (TUI drain task, extension bridge) that already speak the harness API.
Sourcepub fn harness_arc(&self) -> Arc<AgentHarness> ⓘ
pub fn harness_arc(&self) -> Arc<AgentHarness> ⓘ
The Arc handle, for spawning work onto the runtime.
Sourcepub fn scoped_models(&self) -> &[ScopedModel]
pub fn scoped_models(&self) -> &[ScopedModel]
The active scoped-model set ([] → the full catalog is in play).
Sourcepub async fn prompt(
&self,
text: &str,
images: Vec<ImageContent>,
) -> HarnessResult<RunResult>
pub async fn prompt( &self, text: &str, images: Vec<ImageContent>, ) -> HarnessResult<RunResult>
Send a prompt with optional image attachments. Mirrors TS
AgentSession.prompt.
Sourcepub async fn send_message(
&self,
message: AgentMessage,
) -> HarnessResult<RunResult>
pub async fn send_message( &self, message: AgentMessage, ) -> HarnessResult<RunResult>
Send an already-built user message. Mirrors TS
AgentSession.sendUserMessage.
Sourcepub async fn steer(&self, message: AgentMessage) -> HarnessResult<()>
pub async fn steer(&self, message: AgentMessage) -> HarnessResult<()>
Queue a steering message for the in-flight run. Mirrors TS
AgentSession.steer.
Sourcepub async fn follow_up(&self, message: AgentMessage) -> HarnessResult<()>
pub async fn follow_up(&self, message: AgentMessage) -> HarnessResult<()>
Queue a follow-up message for after the in-flight run. Mirrors TS
AgentSession.followUp.
Sourcepub async fn abort(&self) -> HarnessResult<()>
pub async fn abort(&self) -> HarnessResult<()>
Abort the in-flight run. Mirrors TS AgentSession.abort.
Sourcepub async fn model(&self) -> HarnessResult<Model>
pub async fn model(&self) -> HarnessResult<Model>
The current model.
Sourcepub async fn set_model(&self, model: Model) -> HarnessResult<()>
pub async fn set_model(&self, model: Model) -> HarnessResult<()>
Switch the model. Mirrors TS AgentSession.setModel.
Sourcepub async fn thinking_level(&self) -> HarnessResult<ThinkingLevel>
pub async fn thinking_level(&self) -> HarnessResult<ThinkingLevel>
The current thinking level.
Sourcepub async fn set_thinking_level(
&self,
level: ThinkingLevel,
) -> HarnessResult<()>
pub async fn set_thinking_level( &self, level: ThinkingLevel, ) -> HarnessResult<()>
Set the thinking level. Mirrors TS AgentSession.setThinkingLevel.
Sourcepub fn cycle_catalog(&self) -> Vec<Model>
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.
Sourcepub async fn compact(&self, instructions: Option<&str>) -> HarnessResult<()>
pub async fn compact(&self, instructions: Option<&str>) -> HarnessResult<()>
Explicit compaction. Mirrors TS AgentSession.compact.
Sourcepub async fn retry(&self) -> HarnessResult<Option<RunResult>>
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.
Sourcepub async fn tip_id(&self) -> HarnessResult<Option<String>>
pub async fn tip_id(&self) -> HarnessResult<Option<String>>
The current leaf entry id.
Sourcepub async fn entries(&self) -> HarnessResult<Vec<Entry>>
pub async fn entries(&self) -> HarnessResult<Vec<Entry>>
All entries on the session, oldest first.
Sourcepub async fn snapshot(&self) -> HarnessResult<LaneSnapshot>
pub async fn snapshot(&self) -> HarnessResult<LaneSnapshot>
The lane read model. Mirrors the TS runtime lane snapshot.
Sourcepub async fn name(&self) -> HarnessResult<Option<String>>
pub async fn name(&self) -> HarnessResult<Option<String>>
Name/label facts. Mirrors TS AgentSession.setName / setLabel.
Sourcepub async fn set_name(&self, name: Option<&str>) -> HarnessResult<()>
pub async fn set_name(&self, name: Option<&str>) -> HarnessResult<()>
Set (or clear) the session name.
Sourcepub async fn set_label(
&self,
target_id: &str,
label: Option<&str>,
) -> HarnessResult<()>
pub async fn set_label( &self, target_id: &str, label: Option<&str>, ) -> HarnessResult<()>
Attach (or clear) a label on an entry.
Sourcepub async fn value(&self, key: &str) -> HarnessResult<Option<Value>>
pub async fn value(&self, key: &str) -> HarnessResult<Option<Value>>
Read a durable session value (see rpi_harness::session::values).
Sourcepub async fn set_value(&self, key: &str, value: Value) -> HarnessResult<()>
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.
Sourcepub async fn usage_stats(&self) -> HarnessResult<SessionUsageStats>
pub async fn usage_stats(&self) -> HarnessResult<SessionUsageStats>
Rolled-up usage + context stats for the footer.
Sourcepub async fn total_usage(&self) -> HarnessResult<Usage>
pub async fn total_usage(&self) -> HarnessResult<Usage>
The summed usage across every assistant message (for /context).
Sourcepub async fn last_assistant_text(&self) -> HarnessResult<Option<String>>
pub async fn last_assistant_text(&self) -> HarnessResult<Option<String>>
The last finalized assistant text (for /copy). Mirrors TS
AgentSession.getLastAssistantText.
Sourcepub async fn export_to_html(&self, path: &Path) -> HarnessResult<()>
pub async fn export_to_html(&self, path: &Path) -> HarnessResult<()>
exportToHtml(). Mirrors TS AgentSession.exportToHtml.
Sourcepub async fn export_to_jsonl(&self, path: &Path) -> HarnessResult<()>
pub async fn export_to_jsonl(&self, path: &Path) -> HarnessResult<()>
exportToJsonl(). Mirrors TS AgentSession.exportToJsonl.
Sourcepub async fn export_to_markdown(&self, path: &Path) -> HarnessResult<()>
pub async fn export_to_markdown(&self, path: &Path) -> HarnessResult<()>
exportToMarkdown() — the local /export default.
Sourcepub async fn export(
&self,
format: ExportFormat,
path: &Path,
) -> HarnessResult<()>
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.
Sourcepub async fn default_export_file_name(&self, format: ExportFormat) -> String
pub async fn default_export_file_name(&self, format: ExportFormat) -> String
The filename /export would write for format.