pub(crate) async fn run_command(
message: String,
channel: String,
chat_id: String,
sender_id: String,
session_id: Option<String>,
) -> anyhow::Result<()> {
let session = session_id.unwrap_or_else(|| format!("{channel}:{chat_id}"));
let framework = super::builtin_framework().await;
let inbound = serde_json::json!({
"session_id": session,
"channel": channel,
"chat_id": chat_id,
"sender_id": sender_id,
"content": message,
"output_channel": "cli",
});
match framework.process_inbound(inbound).await {
Ok(result) => {
println!("[{}]", result.session_id);
super::print_cli_outbounds(&result.outbounds);
}
Err(e) => {
eprintln!("Error: {e}");
}
}
Ok(())
}