pub struct Runtime<C: Config> {
pub model: Model<C::Provider>,
pub env: Arc<C::Env>,
pub tools: ToolRegistry,
/* private fields */
}Expand description
The crabtalk runtime.
Fields§
§model: Model<C::Provider>§env: Arc<C::Env>§tools: ToolRegistryImplementations§
Source§impl<C: Config> Runtime<C>
impl<C: Config> Runtime<C>
pub fn add_agent(&self, config: AgentConfig)
pub fn upsert_agent(&self, config: AgentConfig) -> AgentConfig
pub fn remove_agent(&self, name: &str) -> bool
pub fn agent(&self, name: &str) -> Option<AgentConfig>
pub fn agents(&self) -> Vec<AgentConfig>
pub async fn add_ephemeral(&self, config: AgentConfig)
pub async fn remove_ephemeral(&self, name: &str)
Source§impl<C: Config> Runtime<C>
impl<C: Config> Runtime<C>
Sourcepub async fn get_or_create_conversation(
&self,
agent: &str,
created_by: &str,
) -> Result<u64>
pub async fn get_or_create_conversation( &self, agent: &str, created_by: &str, ) -> Result<u64>
Get or create a conversation for the given (agent, created_by) identity. Routing order:
- If
(agent, sender)has an active topic, return that topic’s conversation. - Otherwise return/create the tmp conversation for this pair —
in-memory only, no storage I/O, no resume. Topic-bound chats
reach storage via
switch_topic.
Sourcepub async fn load(&self, handle: ConversationHandle) -> Result<u64>
pub async fn load(&self, handle: ConversationHandle) -> Result<u64>
Load a specific conversation by persistent handle.
pub async fn list_active(&self) -> Vec<ActiveConversationInfo>
pub async fn close(&self, id: u64) -> bool
pub async fn steer(&self, conversation_id: u64, content: String) -> Result<()>
pub async fn conversation(&self, id: u64) -> Option<Arc<Mutex<Conversation>>>
pub async fn conversations(&self) -> Vec<Arc<Mutex<Conversation>>>
pub async fn conversation_count(&self) -> usize
pub async fn conversation_id(&self, agent: &str, sender: &str) -> Option<u64>
pub async fn compact(&self, conversation_id: u64) -> Option<String>
pub async fn transfer_to<C2: Config>(&self, dest: &mut Runtime<C2>)
Source§impl<C: Config> Runtime<C>
impl<C: Config> Runtime<C>
pub async fn send_to( &self, conversation_id: u64, content: &str, sender: &str, tool_choice: Option<ToolChoice>, ) -> Result<AgentResponse>
pub fn stream_to( &self, conversation_id: u64, content: &str, sender: &str, tool_choice: Option<ToolChoice>, ) -> impl Stream<Item = AgentEvent> + '_
pub fn guest_stream_to( &self, conversation_id: u64, content: &str, sender: &str, guest: &str, ) -> impl Stream<Item = AgentEvent> + '_
Source§impl<C: Config> Runtime<C>
impl<C: Config> Runtime<C>
Sourcepub async fn switch_topic(
&self,
agent: &str,
sender: &str,
title: &str,
description: Option<&str>,
) -> Result<SwitchOutcome>
pub async fn switch_topic( &self, agent: &str, sender: &str, title: &str, description: Option<&str>, ) -> Result<SwitchOutcome>
Switch the active topic for (agent, sender). Creates a new
topic conversation if the title doesn’t exist yet; resumes the
existing one otherwise. When creating, writes an
EntryKind::Topic memory entry (unless one already exists for
the title) so the topic is searchable via search_topics.
Returns the target conversation_id in the outcome. The caller
is responsible for telling the user which conversation to route
the next message to — this call only updates runtime state.
Source§impl<C: Config> Runtime<C>
impl<C: Config> Runtime<C>
Sourcepub fn new(
model: Model<C::Provider>,
env: Arc<C::Env>,
storage: Arc<C::Storage>,
memory: SharedMemory,
tools: ToolRegistry,
) -> Self
pub fn new( model: Model<C::Provider>, env: Arc<C::Env>, storage: Arc<C::Storage>, memory: SharedMemory, tools: ToolRegistry, ) -> Self
Create a new runtime with the given model, env, storage, memory, and tools.
Sourcepub fn memory(&self) -> &SharedMemory
pub fn memory(&self) -> &SharedMemory
Access the shared memory store.
Auto Trait Implementations§
impl<C> !Freeze for Runtime<C>
impl<C> !RefUnwindSafe for Runtime<C>
impl<C> Send for Runtime<C>
impl<C> Sync for Runtime<C>
impl<C> Unpin for Runtime<C>
impl<C> UnsafeUnpin for Runtime<C>
impl<C> !UnwindSafe for Runtime<C>
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
Mutably borrows from an owned value. Read more