1use async_trait::async_trait;
2
3use super::TextAgent;
4use crate::error::AgentError;
5use crate::state::State;
6
7pub struct TapTextAgent {
10 name: String,
11 func: Box<dyn Fn(&State) + Send + Sync>,
12}
13
14impl TapTextAgent {
15 pub fn new(name: impl Into<String>, f: impl Fn(&State) + Send + Sync + 'static) -> Self {
17 Self {
18 name: name.into(),
19 func: Box::new(f),
20 }
21 }
22}
23
24#[async_trait]
25impl TextAgent for TapTextAgent {
26 fn name(&self) -> &str {
27 &self.name
28 }
29
30 async fn run(&self, state: &State) -> Result<String, AgentError> {
31 (self.func)(state);
32 Ok(String::new())
33 }
34}