use sdforge::error::ApiError;
use sdforge::forge;
#[derive(Debug, Clone, serde::Deserialize, serde::Serialize)]
pub struct ListFunctionsRequest {}
#[derive(Debug, Clone, serde::Serialize)]
pub struct DomainFunctions {
pub domain: String,
pub functions: Vec<String>,
}
#[derive(Debug, Clone, serde::Serialize)]
pub struct ListFunctionsResponse {
pub domains: Vec<DomainFunctions>,
}
#[forge(
name = "list_functions",
version = 1,
path = "/list_functions",
method = "POST",
tool_name = "list_functions",
description = "List all available math functions grouped by domain. Call this first to discover which functions the current build supports (feature-gated domains like time/unit/fx appear only when enabled)."
)]
pub(crate) async fn list_functions(
req: ListFunctionsRequest,
) -> Result<ListFunctionsResponse, ApiError> {
let _ = req; list_functions_inner().await
}
pub(crate) async fn list_functions_inner() -> Result<ListFunctionsResponse, ApiError> {
Ok(ListFunctionsResponse {
domains: crate::function_catalog::DOMAIN_FUNCTIONS
.iter()
.map(|(domain, functions)| DomainFunctions {
domain: (*domain).to_string(),
functions: functions.iter().map(|f| (*f).to_string()).collect(),
})
.collect(),
})
}