summaryrefslogtreecommitdiffstats
path: root/src/agent.h
diff options
context:
space:
mode:
authorEthan Werner <mail@ethanwerner.com>2026-10-10 20:55:33 +0000
committerEthan Werner <mail@ethanwerner.com>2026-10-10 20:56:50 +0000
commitf8423ebea413605b42de23f5dd06c5479d3fa1dd (patch)
tree2612a5eb026c59e7aae01f10a1cf62f2ee43042c /src/agent.h
initial commitHEADmaster
Diffstat (limited to 'src/agent.h')
-rw-r--r--src/agent.h41
1 files changed, 41 insertions, 0 deletions
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 <cjson/cJSON.h>
+
+/* 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