From f8423ebea413605b42de23f5dd06c5479d3fa1dd Mon Sep 17 00:00:00 2001 From: Ethan Werner Date: Sat, 10 Oct 2026 20:55:33 +0000 Subject: initial commit --- src/agent.h | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 src/agent.h (limited to 'src/agent.h') diff --git a/src/agent.h b/src/agent.h new file mode 100644 index 0000000..a18f55e --- /dev/null +++ b/src/agent.h @@ -0,0 +1,41 @@ +#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 -- cgit v1.3.1