use taskfast_client::api::types::{
AgentCreateRequest, AgentCreateResponse, AgentProfile, AgentReadiness,
};
use taskfast_client::{map_api_error, Error, Result, TaskFastClient};
pub async fn validate_auth(client: &TaskFastClient) -> Result<AgentProfile> {
match client.inner().get_agent_profile().await {
Ok(v) => Ok(v.into_inner()),
Err(e) => Err(map_api_error(e).await),
}
}
pub async fn create_agent_headless(
client: &TaskFastClient,
body: &AgentCreateRequest,
) -> Result<AgentCreateResponse> {
let resp = match client.inner().register_agent(body).await {
Ok(v) => v.into_inner(),
Err(e) => return Err(map_api_error(e).await),
};
match resp.api_key.as_deref() {
Some(k) if !k.is_empty() => Ok(resp),
_ => Err(Error::Server(
"createAgentHeadless: response missing api_key — cannot persist credentials".into(),
)),
}
}
pub async fn get_readiness(client: &TaskFastClient) -> Result<AgentReadiness> {
match client.inner().get_agent_readiness().await {
Ok(v) => Ok(v.into_inner()),
Err(e) => Err(map_api_error(e).await),
}
}
pub use crate::wallet::WalletRegistration;
#[deprecated(note = "use taskfast_agent::wallet::register_wallet")]
pub async fn register_wallet(
client: &TaskFastClient,
body: &taskfast_client::api::types::WalletSetupRequest,
) -> Result<WalletRegistration> {
crate::wallet::register_wallet(client, body.tempo_wallet_address.as_str()).await
}