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 client;
12pub mod error;
13pub mod models;
14pub mod stakpak;
15
16pub(crate) mod local;
18
19pub use client::{
21 AgentClient, AgentClientConfig, DEFAULT_STAKPAK_ENDPOINT, ModelOptions, StakpakConfig,
22};
23
24#[async_trait]
25pub trait AgentProvider: Send + Sync {
26 async fn get_my_account(&self) -> Result<GetMyAccountResponse, String>;
28 async fn get_billing_info(
29 &self,
30 account_username: &str,
31 ) -> Result<stakpak_shared::models::billing::BillingResponse, String>;
32
33 async fn list_rulebooks(&self) -> Result<Vec<ListRuleBook>, String>;
35 async fn get_rulebook_by_uri(&self, uri: &str) -> Result<RuleBook, String>;
36 async fn create_rulebook(
37 &self,
38 uri: &str,
39 description: &str,
40 content: &str,
41 tags: Vec<String>,
42 visibility: Option<RuleBookVisibility>,
43 ) -> Result<CreateRuleBookResponse, String>;
44 async fn delete_rulebook(&self, uri: &str) -> Result<(), String>;
45
46 async fn list_agent_sessions(&self) -> Result<Vec<AgentSession>, String>;
48 async fn get_agent_session(&self, session_id: Uuid) -> Result<AgentSession, String>;
49 async fn get_agent_session_stats(&self, session_id: Uuid) -> Result<AgentSessionStats, String>;
50 async fn get_agent_checkpoint(&self, checkpoint_id: Uuid) -> Result<RunAgentOutput, String>;
51 async fn get_agent_session_latest_checkpoint(
52 &self,
53 session_id: Uuid,
54 ) -> Result<RunAgentOutput, String>;
55
56 async fn chat_completion(
58 &self,
59 model: AgentModel,
60 messages: Vec<ChatMessage>,
61 tools: Option<Vec<Tool>>,
62 ) -> Result<ChatCompletionResponse, String>;
63 async fn chat_completion_stream(
64 &self,
65 model: AgentModel,
66 messages: Vec<ChatMessage>,
67 tools: Option<Vec<Tool>>,
68 headers: Option<HeaderMap>,
69 ) -> Result<
70 (
71 std::pin::Pin<
72 Box<dyn Stream<Item = Result<ChatCompletionStreamResponse, ApiStreamError>> + Send>,
73 >,
74 Option<String>,
75 ),
76 String,
77 >;
78 async fn cancel_stream(&self, request_id: String) -> Result<(), String>;
79
80 async fn search_docs(&self, input: &SearchDocsRequest) -> Result<Vec<Content>, String>;
82
83 async fn memorize_session(&self, checkpoint_id: Uuid) -> Result<(), String>;
85 async fn search_memory(&self, input: &SearchMemoryRequest) -> Result<Vec<Content>, String>;
86
87 async fn slack_read_messages(
89 &self,
90 input: &SlackReadMessagesRequest,
91 ) -> Result<Vec<Content>, String>;
92 async fn slack_read_replies(
93 &self,
94 input: &SlackReadRepliesRequest,
95 ) -> Result<Vec<Content>, String>;
96 async fn slack_send_message(
97 &self,
98 input: &SlackSendMessageRequest,
99 ) -> Result<Vec<Content>, String>;
100}