ciab_core/traits/
agent.rs1use async_trait::async_trait;
2use tokio::sync::mpsc;
3use uuid::Uuid;
4
5use crate::error::CiabResult;
6use crate::types::agent::{
7 AgentCommand, AgentConfig, AgentHealth, InteractiveProtocol, PromptMode, SlashCommand,
8};
9use crate::types::llm_provider::AgentLlmCompatibility;
10use crate::types::session::Message;
11use crate::types::stream::StreamEvent;
12
13#[async_trait]
14pub trait AgentProvider: Send + Sync {
15 fn name(&self) -> &str;
17
18 fn base_image(&self) -> &str;
20
21 fn install_commands(&self) -> Vec<String>;
23
24 fn build_start_command(&self, config: &AgentConfig) -> AgentCommand;
26
27 fn prompt_mode(&self) -> PromptMode {
30 PromptMode::StdinJson
31 }
32
33 fn interactive_protocol(&self) -> InteractiveProtocol {
36 InteractiveProtocol::None
37 }
38
39 fn required_env_vars(&self) -> Vec<String>;
41
42 fn parse_output(&self, sandbox_id: &Uuid, raw: &str) -> Vec<StreamEvent>;
44
45 fn validate_config(&self, config: &AgentConfig) -> CiabResult<()>;
47
48 async fn send_message(
50 &self,
51 sandbox_id: &Uuid,
52 session_id: &Uuid,
53 message: &Message,
54 tx: &mpsc::Sender<StreamEvent>,
55 ) -> CiabResult<()>;
56
57 async fn interrupt(&self, sandbox_id: &Uuid) -> CiabResult<()>;
59
60 async fn health_check(&self, sandbox_id: &Uuid) -> CiabResult<AgentHealth>;
62
63 fn slash_commands(&self) -> Vec<SlashCommand> {
65 vec![]
66 }
67
68 fn supported_llm_providers(&self) -> Vec<AgentLlmCompatibility> {
70 vec![]
71 }
72}