#ifndef LLSH_AGENT_H #define LLSH_AGENT_H #include "config.h" #include /* Mirrors agent.rs: provider probe + context-limit fetch (libcurl). */ typedef struct { bool ok; char *detail; /* owned; release with provider_probe_free */ } provider_probe; void provider_probe_free(provider_probe *p); const char *agent_default_base_url(provider_kind p); /* Model-list endpoint for the probe/fetch. Caller frees. */ char *agent_models_url(const config *cfg); /* Auth header for the model-list endpoint. Caller frees each non-NULL. * Ollama sends no auth: both come back NULL. */ void agent_auth(const config *cfg, char **header, char **value); /* GET `url` with a 5s timeout. 0 = HTTP response received (*status, *body * owned); -1 = transport failure (*err owned, body NULL). */ int agent_http_get(const char *url, const char *auth_header, const char *auth_value, long *status, char **body, char **err); /* Pull the window size out of a provider's model-info response. 0 = absent. */ unsigned long extract_context_limit(const cJSON *json, const config *cfg); bool openai_model_present(const char *body, const char *model); bool anthropic_model_present(const char *body, const char *model); /* Best effort: network failures / non-2xx / missing fields -> 0. */ unsigned long agent_fetch_context_limit(const config *cfg); provider_probe agent_probe_provider(const config *cfg); #endif