1#![allow(clippy::too_many_arguments)]
46#![allow(clippy::type_complexity)]
47#![allow(clippy::redundant_closure)]
48#![allow(unused_imports)]
49#![allow(clippy::needless_borrows_for_generic_args)]
50#![allow(clippy::option_as_ref_deref)]
51#![allow(clippy::map_flatten)]
52#![allow(clippy::for_kv_map)]
53
54#[cfg(feature = "postgres")]
59pub static MIGRATOR: sqlx::migrate::Migrator = sqlx::migrate!("./migrations");
60
61pub mod billing_config;
62pub mod config;
63pub mod fleet_secrets;
64pub use billing_config::{BillingConfig, ModelPricingConfig};
65pub use config::{default_qdrant_url, DatabaseConfig, QdrantConfig};
66pub use fleet_secrets::{
67 decrypt_api_key, encrypt_api_key, last_n_visible, EncryptedPayload, FleetSecrets,
68 FleetSecretsError, MasterKey, ProviderOverride,
69};
70
71pub mod vectorstore;
73
74#[cfg(feature = "ares-vector")]
76pub mod ares_vector;
77#[cfg(feature = "chromadb")]
78pub mod chromadb;
79#[cfg(any(feature = "lancedb", feature = "postgres"))]
80pub mod lancedb;
81#[cfg(any(feature = "pgvector", feature = "postgres"))]
82pub mod pgvector;
83#[cfg(any(feature = "pinecone", feature = "postgres"))]
84pub mod pinecone;
85#[cfg(any(feature = "qdrant", feature = "postgres"))]
86pub mod qdrant;
87
88#[cfg(feature = "postgres")]
90pub mod agent_feedback;
92#[cfg(feature = "postgres")]
93pub mod agent_runs;
95#[cfg(feature = "postgres")]
96pub mod alerts;
98#[cfg(feature = "postgres")]
99pub mod audit_log;
101#[cfg(feature = "postgres")]
102pub mod postgres;
104#[cfg(feature = "postgres")]
105pub mod realms;
107#[cfg(feature = "postgres")]
108pub mod tenant_agents;
110#[cfg(feature = "postgres")]
111pub mod tenants;
113#[cfg(feature = "postgres")]
114pub use realms::TenantRealms;
115#[cfg(feature = "postgres")]
116pub mod agent_versions;
118#[cfg(feature = "postgres")]
120pub mod traits;
121#[cfg(feature = "turso")]
123pub mod turso;
124#[cfg(feature = "postgres")]
125pub use agent_versions::AgentVersionInput;
126#[cfg(feature = "postgres")]
127pub mod fleet_provider_secrets;
129#[cfg(feature = "postgres")]
130pub mod oauth_credentials;
132#[cfg(feature = "postgres")]
133pub mod query_builders;
135#[cfg(feature = "postgres")]
136pub mod run_history;
138#[cfg(feature = "postgres")]
139pub mod runtime_providers;
141#[cfg(feature = "postgres")]
142pub mod runtime_tools;
144#[cfg(feature = "postgres")]
145pub mod schedules;
147#[cfg(feature = "postgres")]
148pub mod skills;
150#[cfg(feature = "postgres")]
151pub mod tenant_allowlist;
153#[cfg(feature = "postgres")]
154pub mod tenant_model_tiers;
156#[cfg(feature = "postgres")]
157pub mod token_budgets;
159
160pub use vectorstore::{CollectionInfo, CollectionStats, VectorStore, VectorStoreProvider};
162
163#[cfg(feature = "ares-vector")]
164pub use ares_vector::AresVectorStore;
165#[cfg(feature = "lancedb")]
166pub use lancedb::LanceDBStore;
167#[cfg(feature = "postgres")]
168pub use postgres::PostgresClient;
169#[cfg(feature = "qdrant")]
170pub use qdrant::QdrantVectorStore;
171#[cfg(feature = "postgres")]
172pub use tenants::{TenantDb, UsageSummary};
173#[cfg(feature = "turso")]
174pub use turso::TursoClient;
175
176#[cfg(feature = "postgres")]
177pub type Store = TenantDb;
178
179mod plugins;
180pub use plugins::register_plugins;
181
182pub struct PostgresService;
187impl cordis::Service for PostgresService {
188 fn name(&self) -> &'static str {
189 "postgres"
190 }
191 fn check(&self) -> bool {
192 cfg!(feature = "postgres")
193 }
194}
195
196#[cfg(test)]
197mod tests {
198 #[cfg(feature = "ares-vector")]
199 use super::VectorStoreProvider;
200 use super::{CollectionInfo, CollectionStats};
201 #[cfg(feature = "ares-vector")]
202 use serde_json::json;
203
204 #[test]
205 fn collection_stats_serde_roundtrip() {
206 let stats = CollectionStats {
207 name: "docs".into(),
208 document_count: 42,
209 dimensions: 384,
210 index_size_bytes: Some(1024),
211 distance_metric: "cosine".into(),
212 };
213 let value = serde_json::to_value(&stats).expect("serialize");
214 let back: CollectionStats = serde_json::from_value(value).expect("deserialize");
215 assert_eq!(back.name, "docs");
216 assert_eq!(back.document_count, 42);
217 assert_eq!(back.dimensions, 384);
218 }
219
220 #[test]
221 fn collection_info_serde_roundtrip() {
222 let info = CollectionInfo {
223 name: "embeddings".into(),
224 dimensions: 768,
225 document_count: 10,
226 };
227 let json = serde_json::to_string(&info).expect("serialize");
228 let back: CollectionInfo = serde_json::from_str(&json).expect("deserialize");
229 assert_eq!(back.name, "embeddings");
230 assert_eq!(back.dimensions, 768);
231 }
232
233 #[cfg(feature = "ares-vector")]
234 #[test]
235 fn ares_vector_provider_tagged_json() {
236 let provider = VectorStoreProvider::AresVector {
237 path: Some("./data/vectors".into()),
238 };
239 let value = serde_json::to_value(&provider).expect("serialize");
240 assert_eq!(value["provider"], json!("aresvector"));
241 }
242}