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
21 async fn list_rulebooks(&self) -> Result<Vec<ListRuleBook>, String>;
23 async fn get_rulebook_by_uri(&self, uri: &str) -> Result<RuleBook, String>;
24 async fn create_rulebook(
25 &self,
26 uri: &str,
27 description: &str,
28 content: &str,
29 tags: Vec<String>,
30 visibility: Option<RuleBookVisibility>,
31 ) -> Result<CreateRuleBookResponse, String>;
32 async fn delete_rulebook(&self, uri: &str) -> Result<(), String>;
33
34 async fn list_agent_sessions(&self) -> Result<Vec<AgentSession>, String>;
36 async fn get_agent_session(&self, session_id: Uuid) -> Result<AgentSession, String>;
37 async fn get_agent_session_stats(&self, session_id: Uuid) -> Result<AgentSessionStats, String>;
38 async fn get_agent_checkpoint(&self, checkpoint_id: Uuid) -> Result<RunAgentOutput, String>;
39 async fn get_agent_session_latest_checkpoint(
40 &self,
41 session_id: Uuid,
42 ) -> Result<RunAgentOutput, String>;
43
44 async fn chat_completion(
46 &self,
47 model: AgentModel,
48 messages: Vec<ChatMessage>,
49 tools: Option<Vec<Tool>>,
50 ) -> Result<ChatCompletionResponse, String>;
51 async fn chat_completion_stream(
52 &self,
53 model: AgentModel,
54 messages: Vec<ChatMessage>,
55 tools: Option<Vec<Tool>>,
56 headers: Option<HeaderMap>,
57 ) -> Result<
58 (
59 std::pin::Pin<
60 Box<dyn Stream<Item = Result<ChatCompletionStreamResponse, ApiStreamError>> + Send>,
61 >,
62 Option<String>,
63 ),
64 String,
65 >;
66 async fn cancel_stream(&self, request_id: String) -> Result<(), String>;
67
68 async fn search_docs(&self, input: &SearchDocsRequest) -> Result<Vec<Content>, String>;
70
71 async fn memorize_session(&self, checkpoint_id: Uuid) -> Result<(), String>;
73 async fn search_memory(&self, input: &SearchMemoryRequest) -> Result<Vec<Content>, String>;
74
75 async fn slack_read_messages(
77 &self,
78 input: &SlackReadMessagesRequest,
79 ) -> Result<Vec<Content>, String>;
80 async fn slack_read_replies(
81 &self,
82 input: &SlackReadRepliesRequest,
83 ) -> Result<Vec<Content>, String>;
84 async fn slack_send_message(
85 &self,
86 input: &SlackSendMessageRequest,
87 ) -> Result<Vec<Content>, String>;
88}