1use async_trait::async_trait;
2use futures_util::Stream;
3use models::*;
4use reqwest::header::HeaderMap;
5use rmcp::model::Content;
6use stakpak_shared::models::integrations::openai::{
7 AgentModel, ChatCompletionResponse, ChatCompletionStreamResponse, ChatMessage, Tool,
8};
9use uuid::Uuid;
10
11pub mod error;
12pub mod local;
13pub mod models;
14pub mod remote;
15
16#[async_trait]
17pub trait AgentProvider: Send + Sync {
18 async fn get_my_account(&self) -> Result<GetMyAccountResponse, String>;
20 async fn get_billing_info(
21 &self,
22 account_username: &str,
23 ) -> Result<stakpak_shared::models::billing::BillingResponse, String>;
24
25 async fn list_rulebooks(&self) -> Result<Vec<ListRuleBook>, String>;
27 async fn get_rulebook_by_uri(&self, uri: &str) -> Result<RuleBook, String>;
28 async fn create_rulebook(
29 &self,
30 uri: &str,
31 description: &str,
32 content: &str,
33 tags: Vec<String>,
34 visibility: Option<RuleBookVisibility>,
35 ) -> Result<CreateRuleBookResponse, String>;
36 async fn delete_rulebook(&self, uri: &str) -> Result<(), String>;
37
38 async fn list_agent_sessions(&self) -> Result<Vec<AgentSession>, String>;
40 async fn get_agent_session(&self, session_id: Uuid) -> Result<AgentSession, String>;
41 async fn get_agent_session_stats(&self, session_id: Uuid) -> Result<AgentSessionStats, String>;
42 async fn get_agent_checkpoint(&self, checkpoint_id: Uuid) -> Result<RunAgentOutput, String>;
43 async fn get_agent_session_latest_checkpoint(
44 &self,
45 session_id: Uuid,
46 ) -> Result<RunAgentOutput, String>;
47
48 async fn chat_completion(
50 &self,
51 model: AgentModel,
52 messages: Vec<ChatMessage>,
53 tools: Option<Vec<Tool>>,
54 ) -> Result<ChatCompletionResponse, String>;
55 async fn chat_completion_stream(
56 &self,
57 model: AgentModel,
58 messages: Vec<ChatMessage>,
59 tools: Option<Vec<Tool>>,
60 headers: Option<HeaderMap>,
61 ) -> Result<
62 (
63 std::pin::Pin<
64 Box<dyn Stream<Item = Result<ChatCompletionStreamResponse, ApiStreamError>> + Send>,
65 >,
66 Option<String>,
67 ),
68 String,
69 >;
70 async fn cancel_stream(&self, request_id: String) -> Result<(), String>;
71
72 async fn search_docs(&self, input: &SearchDocsRequest) -> Result<Vec<Content>, String>;
74
75 async fn memorize_session(&self, checkpoint_id: Uuid) -> Result<(), String>;
77 async fn search_memory(&self, input: &SearchMemoryRequest) -> Result<Vec<Content>, String>;
78
79 async fn slack_read_messages(
81 &self,
82 input: &SlackReadMessagesRequest,
83 ) -> Result<Vec<Content>, String>;
84 async fn slack_read_replies(
85 &self,
86 input: &SlackReadRepliesRequest,
87 ) -> Result<Vec<Content>, String>;
88 async fn slack_send_message(
89 &self,
90 input: &SlackSendMessageRequest,
91 ) -> Result<Vec<Content>, String>;
92}