#![recursion_limit = "256"]
#![allow(clippy::pedantic, clippy::all)]
pub mod audit;
pub mod autonomy;
pub mod bench;
pub mod cli;
pub mod color;
pub mod config;
pub mod curator;
pub mod daemon_runtime;
pub mod db;
pub mod embeddings;
pub mod errors;
pub mod federation;
pub mod handlers;
pub mod hnsw;
pub mod identity;
pub mod llm;
pub mod log_paths;
pub mod logging;
pub mod mcp;
pub mod metrics;
pub mod mine;
pub mod models;
pub mod profile;
pub mod replication;
pub mod reranker;
pub mod sizes;
pub mod subscriptions;
pub mod tls;
pub mod toon;
pub mod validate;
#[cfg(feature = "sal")]
pub mod migrate;
#[cfg(feature = "sal")]
pub mod store;
pub fn build_router(
api_key_state: handlers::ApiKeyState,
app_state: handlers::AppState,
) -> axum::Router {
use axum::{
extract::DefaultBodyLimit,
routing::{delete, get, post, put},
};
use tower_http::{cors::CorsLayer, trace::TraceLayer};
axum::Router::new()
.route("/api/v1/health", get(handlers::health))
.route("/metrics", get(handlers::prometheus_metrics))
.route("/api/v1/metrics", get(handlers::prometheus_metrics))
.route("/api/v1/memories", get(handlers::list_memories))
.route("/api/v1/memories", post(handlers::create_memory))
.route("/api/v1/memories/bulk", post(handlers::bulk_create))
.route("/api/v1/memories/{id}", get(handlers::get_memory))
.route("/api/v1/memories/{id}", put(handlers::update_memory))
.route("/api/v1/memories/{id}", delete(handlers::delete_memory))
.route(
"/api/v1/memories/{id}/promote",
post(handlers::promote_memory),
)
.route("/api/v1/search", get(handlers::search_memories))
.route("/api/v1/recall", get(handlers::recall_memories_get))
.route("/api/v1/recall", post(handlers::recall_memories_post))
.route("/api/v1/forget", post(handlers::forget_memories))
.route("/api/v1/consolidate", post(handlers::consolidate_memories))
.route(
"/api/v1/contradictions",
get(handlers::detect_contradictions),
)
.route("/api/v1/links", post(handlers::create_link))
.route("/api/v1/links", delete(handlers::delete_link))
.route("/api/v1/links/{id}", get(handlers::get_links))
.route(
"/api/v1/namespaces",
get(handlers::get_namespace_standard_qs),
)
.route(
"/api/v1/namespaces",
post(handlers::set_namespace_standard_qs),
)
.route(
"/api/v1/namespaces",
delete(handlers::clear_namespace_standard_qs),
)
.route(
"/api/v1/namespaces/{ns}/standard",
post(handlers::set_namespace_standard),
)
.route(
"/api/v1/namespaces/{ns}/standard",
get(handlers::get_namespace_standard),
)
.route(
"/api/v1/namespaces/{ns}/standard",
delete(handlers::clear_namespace_standard),
)
.route("/api/v1/taxonomy", get(handlers::get_taxonomy))
.route("/api/v1/check_duplicate", post(handlers::check_duplicate))
.route("/api/v1/entities", post(handlers::entity_register))
.route(
"/api/v1/entities/by_alias",
get(handlers::entity_get_by_alias),
)
.route("/api/v1/kg/timeline", get(handlers::kg_timeline))
.route("/api/v1/kg/invalidate", post(handlers::kg_invalidate))
.route("/api/v1/kg/query", post(handlers::kg_query))
.route("/api/v1/stats", get(handlers::get_stats))
.route("/api/v1/gc", post(handlers::run_gc))
.route("/api/v1/export", get(handlers::export_memories))
.route("/api/v1/import", post(handlers::import_memories))
.route("/api/v1/archive", get(handlers::list_archive))
.route("/api/v1/archive", post(handlers::archive_by_ids))
.route("/api/v1/archive", delete(handlers::purge_archive))
.route(
"/api/v1/archive/{id}/restore",
post(handlers::restore_archive),
)
.route("/api/v1/archive/stats", get(handlers::archive_stats))
.route("/api/v1/agents", get(handlers::list_agents))
.route("/api/v1/agents", post(handlers::register_agent))
.route("/api/v1/pending", get(handlers::list_pending))
.route(
"/api/v1/pending/{id}/approve",
post(handlers::approve_pending),
)
.route(
"/api/v1/pending/{id}/reject",
post(handlers::reject_pending),
)
.route("/api/v1/sync/push", post(handlers::sync_push))
.route("/api/v1/sync/since", get(handlers::sync_since))
.route("/api/v1/capabilities", get(handlers::get_capabilities))
.route("/api/v1/notify", post(handlers::notify))
.route("/api/v1/inbox", get(handlers::get_inbox))
.route("/api/v1/subscriptions", post(handlers::subscribe))
.route("/api/v1/subscriptions", delete(handlers::unsubscribe))
.route("/api/v1/subscriptions", get(handlers::list_subscriptions))
.route("/api/v1/session/start", post(handlers::session_start))
.layer(axum::middleware::from_fn_with_state(
api_key_state,
handlers::api_key_auth,
))
.layer(TraceLayer::new_for_http())
.layer(DefaultBodyLimit::max(2 * 1024 * 1024))
.layer(CorsLayer::new())
.with_state(app_state)
}