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/provider.h | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 src/provider.h (limited to 'src/provider.h') diff --git a/src/provider.h b/src/provider.h new file mode 100644 index 0000000..ae60896 --- /dev/null +++ b/src/provider.h @@ -0,0 +1,41 @@ +#ifndef LLSH_PROVIDER_H +#define LLSH_PROVIDER_H + +#include + +#include "llm.h" +#include "mcp.h" +#include "session.h" + +/* The session-bound provider layer: implements the `llsh_model` vtable on + * top of llm.h's protocol layer, wiring in the session (config, preamble, + * allowed tools, .agents), the built-in + MCP tool registry, and the + * session's emit callback. */ + +/* Which one-shot role this model serves. `complete` uses the matching + * preamble; `stream` (the agent turn) always uses the session preamble. */ +typedef enum { + PROV_ROLE_MAIN = 0, + PROV_ROLE_SUMMARIZER, + PROV_ROLE_EVALUATOR, + PROV_ROLE_RUBRIC, +} provider_role; + +/* Create a session-bound model. `sess` may be NULL until + * provider_model_attach; `mcp` may be NULL (no MCP tools). */ +llsh_model *provider_model_new(session *sess, mcp_registry *mcp, + provider_role role); +void provider_model_attach(llsh_model *m, session *sess); + +/* Test hook: build the request body (without sending) for the session's + * current config, preamble, and tool set, for a single one-shot prompt. + * Caller frees the returned string. */ +char *provider_preview_request(session *sess, const char *prompt, + bool with_tools); + +/* On stop, an assistant message can carry more tool calls than the + * tool-result messages that follow it (we stopped mid-loop). Trim the + * surplus calls so the committed history stays a valid request. */ +void provider_trim_dangling_calls(message *msgs, size_t n); + +#endif /* LLSH_PROVIDER_H */ -- cgit v1.3.1