1pub mod agent;
27pub mod analytics;
28pub mod client;
29pub mod config;
30pub mod error;
31pub mod executions;
32pub mod feedback;
33pub mod search;
34pub mod services;
35pub mod skills;
36pub mod types;
37
38pub use agent::AgentApi;
39pub use analytics::AnalyticsApi;
40pub use client::ApiClient;
41pub use config::ConfigApi;
42pub use error::{ApiError, ApiResult};
43pub use executions::ExecutionsApi;
44pub use feedback::{
45 FeedbackApi, FeedbackEntry, GetFeedbackRequest, GetFeedbackResponse, SubmitFeedbackRequest,
46 SubmitFeedbackResponse,
47};
48pub use search::SearchApi;
49pub use services::ServicesApi;
50pub use skills::SkillsApi;
51pub use types::*;
52
53#[derive(Clone)]
55pub struct Api {
56 pub skills: SkillsApi,
58 pub executions: ExecutionsApi,
60 pub search: SearchApi,
62 pub config: ConfigApi,
64 pub services: ServicesApi,
66 pub agent: AgentApi,
68 pub feedback: FeedbackApi,
70 pub analytics: AnalyticsApi,
72}
73
74impl Default for Api {
75 fn default() -> Self {
76 Self::new()
77 }
78}
79
80impl Api {
81 pub fn new() -> Self {
83 let client = ApiClient::local();
84 Self::with_client(client)
85 }
86
87 pub fn with_base_url(base_url: impl Into<String>) -> Self {
89 let client = ApiClient::new(base_url);
90 Self::with_client(client)
91 }
92
93 pub fn with_host(host: &str, port: u16) -> Self {
95 let client = ApiClient::with_host(host, port);
96 Self::with_client(client)
97 }
98
99 pub fn with_client(client: ApiClient) -> Self {
101 Self {
102 skills: SkillsApi::new(client.clone()),
103 executions: ExecutionsApi::new(client.clone()),
104 search: SearchApi::new(client.clone()),
105 config: ConfigApi::new(client.clone()),
106 services: ServicesApi::new(client.clone()),
107 agent: AgentApi::new(client.clone()),
108 feedback: FeedbackApi::new(client.clone()),
109 analytics: AnalyticsApi::new(client),
110 }
111 }
112
113 pub async fn is_available(&self) -> bool {
115 self.config.is_healthy().await
116 }
117
118 pub async fn server_version(&self) -> ApiResult<String> {
120 let version = self.config.version().await?;
121 Ok(version.version)
122 }
123}
124
125pub fn api() -> Api {
127 Api::new()
128}