pub trait RpcSessionHost: Send + Sync {
Show 37 methods
// Required methods
fn prompt(
&self,
message: String,
images: Vec<ImageContent>,
streaming_behavior: Option<StreamingBehavior>,
preflight: PreflightCallback,
) -> BoxFuture<'static, Result<(), String>>;
fn steer(
&self,
message: String,
images: Vec<ImageContent>,
) -> BoxFuture<'static, Result<(), String>>;
fn follow_up(
&self,
message: String,
images: Vec<ImageContent>,
) -> BoxFuture<'static, Result<(), String>>;
fn abort(&self) -> BoxFuture<'static, ()>;
fn get_state(&self) -> BoxFuture<'static, RpcSessionState>;
fn get_available_models(&self) -> BoxFuture<'static, Vec<Model>>;
fn set_model(&self, model: Model) -> BoxFuture<'static, Result<(), String>>;
fn cycle_model(&self) -> BoxFuture<'static, Option<ModelCycleResult>>;
fn set_thinking_level(
&self,
level: ModelThinkingLevel,
) -> BoxFuture<'static, bool>;
fn cycle_thinking_level(
&self,
) -> BoxFuture<'static, Option<ModelThinkingLevel>>;
fn set_steering_mode(&self, mode: QueueMode) -> BoxFuture<'static, ()>;
fn set_follow_up_mode(&self, mode: QueueMode) -> BoxFuture<'static, ()>;
fn compact(
&self,
custom_instructions: Option<String>,
) -> BoxFuture<'static, Result<CompactionResult, String>>;
fn set_auto_compaction(&self, enabled: bool) -> BoxFuture<'static, ()>;
fn set_auto_retry(&self, enabled: bool) -> BoxFuture<'static, ()>;
fn abort_retry(&self) -> BoxFuture<'static, ()>;
fn execute_bash(
&self,
command: String,
exclude_from_context: Option<bool>,
) -> BoxFuture<'static, Result<BashResult, String>>;
fn abort_bash(&self) -> BoxFuture<'static, ()>;
fn get_session_stats(&self) -> BoxFuture<'static, SessionStats>;
fn export_to_html(
&self,
output_path: Option<String>,
) -> BoxFuture<'static, Result<String, String>>;
fn set_session_name(
&self,
name: String,
) -> BoxFuture<'static, Result<(), String>>;
fn new_session(
&self,
parent_session: Option<String>,
) -> BoxFuture<'static, Result<bool, String>>;
fn switch_session(
&self,
session_path: String,
) -> BoxFuture<'static, Result<bool, String>>;
fn fork(
&self,
entry_id: String,
position: ForkPosition,
) -> BoxFuture<'static, Result<ForkOutcome, String>>;
fn get_entries(&self) -> BoxFuture<'static, Vec<SessionEntry>>;
fn get_leaf_id(&self) -> BoxFuture<'static, Option<String>>;
fn get_tree(&self) -> BoxFuture<'static, Vec<RpcSessionTreeNode>>;
fn get_fork_messages(&self) -> BoxFuture<'static, Vec<ForkMessage>>;
fn get_last_assistant_text(&self) -> BoxFuture<'static, Option<String>>;
fn get_messages(&self) -> BoxFuture<'static, Vec<AgentMessage>>;
fn get_commands(&self) -> BoxFuture<'static, Vec<RpcSlashCommand>>;
fn subscribe(
&self,
listener: Arc<dyn Fn(&AgentSessionEvent) + Send + Sync>,
) -> Box<dyn Fn() + Send + Sync>;
fn register_backpressure_hook(
&self,
hook: Arc<dyn Fn() -> BoxFuture<'static, ()> + Send + Sync>,
) -> Box<dyn Fn() + Send + Sync>;
fn bind_extensions_rpc(
&self,
bindings: ExtensionBindings,
) -> BoxFuture<'static, Result<(), String>>;
fn dispose(&self) -> BoxFuture<'static, ()>;
fn set_rebind(&self, callback: Option<RebindCallback>);
// Provided method
fn host_extension_runner(&self) -> Option<Arc<HostExtensionRunner>> { ... }
}Expand description
Abstracts the AgentSessionRuntime + AgentSession surface consumed by the
31 RpcCommand variants.
All async methods return BoxFuture<'static> so they can be tokio::spawn’d
without borrowing the host; the preflight callback fires synchronously
during the first poll of prompt, which is how the prompt-response
frame is enqueued before any agent event in the central write FIFO.
Required Methods§
Sourcefn prompt(
&self,
message: String,
images: Vec<ImageContent>,
streaming_behavior: Option<StreamingBehavior>,
preflight: PreflightCallback,
) -> BoxFuture<'static, Result<(), String>>
fn prompt( &self, message: String, images: Vec<ImageContent>, streaming_behavior: Option<StreamingBehavior>, preflight: PreflightCallback, ) -> BoxFuture<'static, Result<(), String>>
Submit a user prompt. The preflight callback fires with true on
accept (before the run starts) or false on reject.
Sourcefn steer(
&self,
message: String,
images: Vec<ImageContent>,
) -> BoxFuture<'static, Result<(), String>>
fn steer( &self, message: String, images: Vec<ImageContent>, ) -> BoxFuture<'static, Result<(), String>>
Steer into the active turn.
Sourcefn follow_up(
&self,
message: String,
images: Vec<ImageContent>,
) -> BoxFuture<'static, Result<(), String>>
fn follow_up( &self, message: String, images: Vec<ImageContent>, ) -> BoxFuture<'static, Result<(), String>>
Queue a follow-up after the current turn finishes.
Sourcefn get_state(&self) -> BoxFuture<'static, RpcSessionState>
fn get_state(&self) -> BoxFuture<'static, RpcSessionState>
Snapshot the current session for the get_state RPC.
Sourcefn get_available_models(&self) -> BoxFuture<'static, Vec<Model>>
fn get_available_models(&self) -> BoxFuture<'static, Vec<Model>>
List available models from the model runtime.
Sourcefn set_model(&self, model: Model) -> BoxFuture<'static, Result<(), String>>
fn set_model(&self, model: Model) -> BoxFuture<'static, Result<(), String>>
Set the active model.
Sourcefn cycle_model(&self) -> BoxFuture<'static, Option<ModelCycleResult>>
fn cycle_model(&self) -> BoxFuture<'static, Option<ModelCycleResult>>
Cycle to the next model (scoped or all-available).
Sourcefn set_thinking_level(
&self,
level: ModelThinkingLevel,
) -> BoxFuture<'static, bool>
fn set_thinking_level( &self, level: ModelThinkingLevel, ) -> BoxFuture<'static, bool>
Set the thinking level. Resolves true only when the level change was
durably committed (or was already effective).
Sourcefn cycle_thinking_level(&self) -> BoxFuture<'static, Option<ModelThinkingLevel>>
fn cycle_thinking_level(&self) -> BoxFuture<'static, Option<ModelThinkingLevel>>
Cycle to the next thinking level.
Sourcefn set_steering_mode(&self, mode: QueueMode) -> BoxFuture<'static, ()>
fn set_steering_mode(&self, mode: QueueMode) -> BoxFuture<'static, ()>
Set steering queue drain mode.
Sourcefn set_follow_up_mode(&self, mode: QueueMode) -> BoxFuture<'static, ()>
fn set_follow_up_mode(&self, mode: QueueMode) -> BoxFuture<'static, ()>
Set follow-up queue drain mode.
Sourcefn compact(
&self,
custom_instructions: Option<String>,
) -> BoxFuture<'static, Result<CompactionResult, String>>
fn compact( &self, custom_instructions: Option<String>, ) -> BoxFuture<'static, Result<CompactionResult, String>>
Compact the session.
Sourcefn set_auto_compaction(&self, enabled: bool) -> BoxFuture<'static, ()>
fn set_auto_compaction(&self, enabled: bool) -> BoxFuture<'static, ()>
Enable / disable auto-compaction.
Sourcefn set_auto_retry(&self, enabled: bool) -> BoxFuture<'static, ()>
fn set_auto_retry(&self, enabled: bool) -> BoxFuture<'static, ()>
Enable / disable auto-retry.
Sourcefn abort_retry(&self) -> BoxFuture<'static, ()>
fn abort_retry(&self) -> BoxFuture<'static, ()>
Abort in-flight retry sleep.
Sourcefn execute_bash(
&self,
command: String,
exclude_from_context: Option<bool>,
) -> BoxFuture<'static, Result<BashResult, String>>
fn execute_bash( &self, command: String, exclude_from_context: Option<bool>, ) -> BoxFuture<'static, Result<BashResult, String>>
Execute a bash command.
Sourcefn abort_bash(&self) -> BoxFuture<'static, ()>
fn abort_bash(&self) -> BoxFuture<'static, ()>
Abort a running bash command.
Sourcefn get_session_stats(&self) -> BoxFuture<'static, SessionStats>
fn get_session_stats(&self) -> BoxFuture<'static, SessionStats>
Aggregate session statistics for get_session_stats.
Sourcefn export_to_html(
&self,
output_path: Option<String>,
) -> BoxFuture<'static, Result<String, String>>
fn export_to_html( &self, output_path: Option<String>, ) -> BoxFuture<'static, Result<String, String>>
Export the session to HTML. Returns the written file path.
Sourcefn set_session_name(
&self,
name: String,
) -> BoxFuture<'static, Result<(), String>>
fn set_session_name( &self, name: String, ) -> BoxFuture<'static, Result<(), String>>
Set the session display name.
Sourcefn new_session(
&self,
parent_session: Option<String>,
) -> BoxFuture<'static, Result<bool, String>>
fn new_session( &self, parent_session: Option<String>, ) -> BoxFuture<'static, Result<bool, String>>
Start a new session. Returns true when cancelled by an extension hook.
Sourcefn switch_session(
&self,
session_path: String,
) -> BoxFuture<'static, Result<bool, String>>
fn switch_session( &self, session_path: String, ) -> BoxFuture<'static, Result<bool, String>>
Switch to another session file. Returns true when cancelled.
Sourcefn fork(
&self,
entry_id: String,
position: ForkPosition,
) -> BoxFuture<'static, Result<ForkOutcome, String>>
fn fork( &self, entry_id: String, position: ForkPosition, ) -> BoxFuture<'static, Result<ForkOutcome, String>>
Fork the session. Returns the fork outcome.
Sourcefn get_entries(&self) -> BoxFuture<'static, Vec<SessionEntry>>
fn get_entries(&self) -> BoxFuture<'static, Vec<SessionEntry>>
All session entries.
Sourcefn get_leaf_id(&self) -> BoxFuture<'static, Option<String>>
fn get_leaf_id(&self) -> BoxFuture<'static, Option<String>>
Current leaf entry id.
Sourcefn get_tree(&self) -> BoxFuture<'static, Vec<RpcSessionTreeNode>>
fn get_tree(&self) -> BoxFuture<'static, Vec<RpcSessionTreeNode>>
Session tree (wire-facing nodes).
Sourcefn get_fork_messages(&self) -> BoxFuture<'static, Vec<ForkMessage>>
fn get_fork_messages(&self) -> BoxFuture<'static, Vec<ForkMessage>>
Forkable user messages.
Sourcefn get_last_assistant_text(&self) -> BoxFuture<'static, Option<String>>
fn get_last_assistant_text(&self) -> BoxFuture<'static, Option<String>>
Last assistant text content, if any.
Sourcefn get_messages(&self) -> BoxFuture<'static, Vec<AgentMessage>>
fn get_messages(&self) -> BoxFuture<'static, Vec<AgentMessage>>
All agent messages.
Sourcefn get_commands(&self) -> BoxFuture<'static, Vec<RpcSlashCommand>>
fn get_commands(&self) -> BoxFuture<'static, Vec<RpcSlashCommand>>
Available slash commands (extension + prompt + skill).
Sourcefn subscribe(
&self,
listener: Arc<dyn Fn(&AgentSessionEvent) + Send + Sync>,
) -> Box<dyn Fn() + Send + Sync>
fn subscribe( &self, listener: Arc<dyn Fn(&AgentSessionEvent) + Send + Sync>, ) -> Box<dyn Fn() + Send + Sync>
Subscribe to public session events. Returns an unsubscribe closure.
Sourcefn register_backpressure_hook(
&self,
hook: Arc<dyn Fn() -> BoxFuture<'static, ()> + Send + Sync>,
) -> Box<dyn Fn() + Send + Sync>
fn register_backpressure_hook( &self, hook: Arc<dyn Fn() -> BoxFuture<'static, ()> + Send + Sync>, ) -> Box<dyn Fn() + Send + Sync>
Register a backpressure hook invoked when the agent has pending events.
Sourcefn bind_extensions_rpc(
&self,
bindings: ExtensionBindings,
) -> BoxFuture<'static, Result<(), String>>
fn bind_extensions_rpc( &self, bindings: ExtensionBindings, ) -> BoxFuture<'static, Result<(), String>>
Bind extensions for RPC mode.
Sourcefn set_rebind(&self, callback: Option<RebindCallback>)
fn set_rebind(&self, callback: Option<RebindCallback>)
Set the rebind callback invoked after session replacement.
Provided Methods§
Sourcefn host_extension_runner(&self) -> Option<Arc<HostExtensionRunner>>
fn host_extension_runner(&self) -> Option<Arc<HostExtensionRunner>>
Current concrete extension host, when this session uses one.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".