pub struct ChatbotFrontend {
pub chat_id: String,
pub session_id: String,
pub platform_sender: Arc<dyn PlatformSender>,
pub confirmer: Arc<Confirmer>,
pub db: Arc<Mutex<Connection>>,
pub buffer: Mutex<String>,
pub last_msg_id: Mutex<Option<String>>,
pub progress_hint_sent: Mutex<bool>,
pub auto_approve: bool,
}Expand description
Per-session Frontend trait implementation for Bot platforms.
Each chat (group or private) gets its own ChatbotFrontend instance.
TextDelta events are buffered and flushed once at TurnComplete with
full Markdown sanitization to ensure clean output on platforms like QQ.
Fields§
§chat_id: StringThe chat this frontend belongs to (group:{id} or private:{id}).
session_id: StringThe session ID for database storage.
platform_sender: Arc<dyn PlatformSender>Platform message sender (shared across all frontends).
confirmer: Arc<Confirmer>Tool confirmation coordinator (shared).
db: Arc<Mutex<Connection>>Database connection for persisting messages.
buffer: Mutex<String>Buffer to accumulate text until TurnComplete.
last_msg_id: Mutex<Option<String>>ID of the last message sent (for edit-based updates, e.g., replacing a progress hint with the actual response).
progress_hint_sent: Mutex<bool>Whether a progress hint has already been sent this turn (rate limit).
auto_approve: boolAuto-approve all tool calls.
Implementations§
Source§impl ChatbotFrontend
impl ChatbotFrontend
Sourcepub fn new(
chat_id: String,
session_id: String,
platform_sender: Arc<dyn PlatformSender>,
confirmer: Arc<Confirmer>,
db: Arc<Mutex<Connection>>,
auto_approve: bool,
) -> Self
pub fn new( chat_id: String, session_id: String, platform_sender: Arc<dyn PlatformSender>, confirmer: Arc<Confirmer>, db: Arc<Mutex<Connection>>, auto_approve: bool, ) -> Self
Create a new ChatbotFrontend for chat_id.
Sourcepub async fn save_user_message(&self, content: &str)
pub async fn save_user_message(&self, content: &str)
Save a user message to the database (called from manager).
Trait Implementations§
Source§impl Frontend for ChatbotFrontend
impl Frontend for ChatbotFrontend
Source§fn on_event<'life0, 'async_trait>(
&'life0 self,
event: AgentEvent,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn on_event<'life0, 'async_trait>(
&'life0 self,
event: AgentEvent,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Source§fn request_tool_confirmation<'life0, 'life1, 'async_trait>(
&'life0 self,
info: &'life1 ToolCallInfo,
) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn request_tool_confirmation<'life0, 'life1, 'async_trait>(
&'life0 self,
info: &'life1 ToolCallInfo,
) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
true if the user approved, false if rejected.